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.


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;
  • 1
    $\begingroup$ why don't you just extract Ihsv(:,:,1) or Ihsv(:,:,2) for further processing $\endgroup$ – lennon310 Feb 28 '14 at 17:40
  • $\begingroup$ yes, after extracting h and s layers as you mentioned.. how do I plot the distribution $\endgroup$ – 0cool Feb 28 '14 at 17:41
  • $\begingroup$ 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) $\endgroup$ – lennon310 Feb 28 '14 at 17:54
  • $\begingroup$ Okay!, when in the case of normalized values, how should I do it? $\endgroup$ – 0cool Feb 28 '14 at 18:01
  • $\begingroup$ chroma(round(cb(i)*256), round(cr(i)*256)) = chroma(round(cb(i)*256), round(cr(i)*256)) + 1; $\endgroup$ – lennon310 Feb 28 '14 at 18:16

Have a look at File Exchange Submission - RGB/HSV Distribution on visualization of RGB/HSV distribution in a given image:

hsv_distribution(inputImage, 5)

It should do what you're after as the result is like:

enter image description here

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.