Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

which are the ranges in hsv image representation in matlab?

i've to compare several images of the same scene taken from different devices/position. To do so, i want to quantize the colors in order to remove some color representation differences due to device and illumination. If i work in RGB i know that matlab represent each channel in the range [0 255], if i work in YCbCr i know that the three ranges are[16 235] and [16 240], but if i wanted to work in HSV color space i just know that converting with rgb2hsv i get an image which each channel is a double... but i don't know if all range between 0 and 1 are used for all the three channels.... so that i cannot make a quantization without this information.

like image 551
user2614596 Avatar asked Nov 26 '25 04:11

user2614596


1 Answers

Parag basically answered your question, but if you want physical proof, you can do what chappjc suggested and just... try it yourself! Read in an image, convert it to HSV using rgb2hsv, and take a look at the distribution of values. For example, using onion.png that is part of MATLAB's system path, try something like:

im = imread('onion.png');
out = rgb2hsv(im);
str = 'HSV';
for idx = 1 : 3
    disp(['Range of ', str(idx)]);
    disp([min(min(out(:,:,idx))) max(max(out(:,:,idx)))]);
end

The above code will read in each channel and display the minimum and maximum in each (Hue, Saturation and Value). This is what I get:

Range of H
         0    0.9991

Range of S
    0.0791    1.0000

Range of V
    0.0824    1.0000

As you can see, the values range between [0,1]. Have fun!

like image 176
rayryeng Avatar answered Nov 29 '25 19:11

rayryeng



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!