-
November 5th, 2009, 09:15 AM
#1
HSI in matrix to an image
Hi, im making a program that can convert RGB to HSI. Hue, Saturation and Intensity.
Im using OpenCV for doing it. But i however cant used the premade funcs in opencv.
Im loading my input image into a matrix, and im dragging out the rgb-info for each pixel and converting them to HSI values. And this is gonna run in a loop for x and y to process through the whole image.
The RGB image is displayed by 3 values per pixel in the range of 0-255. if a value exceeds 255, it will start from 0 again. Meaning if u by some reason get a value of 300 into a pixel's color channel, then it will display as 45 instead.
The HSI color space works with 3 different brackets, 1 for each channel.
H is 0-360
S is 0-1
I is 255
"H"and "I" works with whole numbers, but "S" works with 0.3 etc.
The output i should get from this would be 3 windows with 3 images, displaying the value of H,S,I. But i cant figure out how to get the 0-360 value working.
So question is more or less if there is some "smart" way of doing it, or if it have to be divided by 255, so that it would be relative colors shown in RGB, but representing their equivalent HSI value.
-
November 5th, 2009, 09:33 AM
#2
Re: HSI in matrix to an image
For S you need to map 0-1 interval to 0-255. For I, you need to map 0-360 interval to 0-255. Resulting arrays should be used only for graphic representation. If you need to keep computed HSI values, keep them in original format.
-
November 5th, 2009, 09:57 AM
#3
Re: HSI in matrix to an image
Yes, but what channels should i use for each of the 3 pictures ?
Like should i set R-channel = H
G-channel = S
B-channel = I
or how would it be done ?
http://en.wikipedia.org/wiki/HSI_color_space
Half way down the page, there is a picture split up in to 3 different pictures.
This one:
If u see on the picture, the 1st is normal, 2nd uses more than 1 channel to visualise it, 2nd and 3rd seems like they use fewer.
-
November 5th, 2009, 10:07 AM
#4
Re: HSI in matrix to an image
I would try the same order: RGB -> HSI. Just remember that Windows bitmap internally keeps colors in BGR order.
-
November 5th, 2009, 05:08 PM
#5
Re: HSI in matrix to an image
yep, decided to just go with that. Caus its just a way to visualize some values that arent directly able to be seen visually, as it is with RGB. But ty for the quick replyes.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|