# How Do I Plot Color Distribution of HSV Image in MATLAB

I have a dataset of images representing human skin. How do I plot the skin color distribution in HSV color space and YCBCR color space. However, I'd like ignore the "value" or "brightness" in both color spaces and analyze rest of the layers.

edit

The below is the code, I found to plot the distribution for ycbcr but don't understand what it means. Can anyone explain it please?

chroma = zeros(256);
cb = imycc(:,:,2);
cb = reshape(cb, 1, numel(cb));
cb = round(cb);

cr = imycc(:,:,3);
cr = reshape(cr, 1, numel(cr));
cr = round(cr);

for i = 1:length(cb)
chroma(cb(i), cr(i)) = chroma(cb(i), cr(i)) + 1;
end
surf(chroma)

• why don't you just extract Ihsv(:,:,1) or Ihsv(:,:,2) for further processing Feb 28, 2014 at 17:40
• yes, after extracting h and s layers as you mentioned.. how do I plot the distribution Feb 28, 2014 at 17:41
• The code is pretty clear, it just count the number of (cb(i),cr(i)) combinations under the assumption of cb, and cr value all locates within the range of 1-256 (or 0-255 in your case) Feb 28, 2014 at 17:54
• Okay!, when in the case of normalized values, how should I do it? Feb 28, 2014 at 18:01
• chroma(round(cb(i)*256), round(cr(i)*256)) = chroma(round(cb(i)*256), round(cr(i)*256)) + 1; Feb 28, 2014 at 18:16

hsv_distribution(inputImage, 5) 