how to generate hsv color and hsv range

4 Ansichten (letzte 30 Tage)
Mohammad Golam Kibria
Mohammad Golam Kibria am 25 Apr. 2011
Hi,
I want to generate hsv color automatically. The process is i have a matrix
color=zeros([10,10,3],'double');
i want to assign hue, saturation and value as follows:
color(:,:,1)=.001;//hue color(:,:,2)=.002;//saturation color(:,:,3)=.003;//value
then imshow(color);
i saved this file with imwrite function. Then I want to read the file and get the hsv value of color file.but it does not give me that value as I assigned.
How to get the appropriate value I assigned and also the range of
Hue,saturation and value i.e min and max range of Hue,saturation and value,
Can any one help me in this regard. Thanks
Golam Kibria

Antworten (1)

Walter Roberson
Walter Roberson am 25 Apr. 2011
None of the file formats supported by imwrite() are able to write floating point numbers for the components. PPM files support raw binary of up to 16 bits per channel, but the smallest floating point format that MATLAB supports is 32 bits per channel. All other file formats for color images scale the RGB values by 2^N (where N is the number of bits per channel) and convert the result to integers. Depending on the file format chosen, 8 or 16 bits per channel are typical. A file format that only supports 8 bits per channel would have a minimum distinguishable RGB value of 1/256 which is about 0.004 . Therefore, unless you use a file format with more than 8 bits per channel, your values of 0.01 will be converted into binary 0.
imshow() is not able to display HSV images directly.
None of the file formats supported by imwrite() is intended to store HSV images; on the other hand, the lossless formats do not care what the components represent... just don't ask to display the resulting file. Beware that if you use a lossy image format such as JPEG that there will be assumptions about the meaning of the components, and so storing HSV values and allowing those to be compressed could potentially result in significant image alteration.
Please see rgb2hsv() and hsv2rgb().

Kategorien

Mehr zu Modify Image Colors finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by