How to convert the RGB color map into an HSV color map

6 views (last 30 days)
Hi All,
I need to do these steps :
1-Convert an RGB image to colormap say M
2-Convert this RGB colormap M to an HSV colormap say cmap
By using this conversion in MATLAB cmap = rgb2hsv (M) that converts an RGB colormap M to an HSV colormap,But my question How can I get the RGB colormap M firstly then to us it in rgb2hsv(M) function? Please could anyone explain to me in example,Thanks in advance for Help.
I'll wait your answer impatiently,
  1 Comment
hamed abdulaziz
hamed abdulaziz on 29 Dec 2013
Edited: hamed abdulaziz on 29 Dec 2013
I tried this(is it correct?) :
RGB=imread('d:\168.bmp');
n=65536;
% Converts the RGB image to an indexed image X ;n = colors
[IND,map] = rgb2ind(RGB,n);
% Convert RGB colormap to HSV colormap(is it correct?)
cmap=rgb2hsv(map);
% Calcula the color variance of the HSV colormap
color_variance=var(cmap);
Is the color_variance represent the actual color variance for an image,because I have three coloumns!!!

Sign in to comment.

Accepted Answer

Image Analyst
Image Analyst on 29 Dec 2013
No that does not make any sense. You can't just apply some different colormap to an indexed image and expect it to look sensible. It will look like garbage. And calculating the variance of a colormap is meaningless. Perhaps you want the color frequency image like this calculates but I don't know.
I think perhaps you're getting color map confused with colorspace. You want to do something, though I don't know what it is. And you think that this colormap approach is the way to do it, but it's not - it's a dead end. So why don't you tell me what you really want to do and I can recommend an approach. For example you want so segment out pixels of some particular color out of an image, or you want to classify the image into 5 different color classes.
  9 Comments
Image Analyst
Image Analyst on 29 Dec 2013
Transform into lab color space with makecform(). Find the mean L, a, and b in the region of interest. Then calculate delta images:
deltaLimage = Limage - meanL;
deltaAimage = Aimage - meanA;
deltaBimage = Bimage - meanB;
% Calculate deltaE image
deltaE = sqrt(deltaLimage .^ 2 + deltaAimage .^ 2 + deltaBimage .^ 2);
I have a delta E demo in my File Exchange.

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!