2
$\begingroup$

As per this resource, there is an easy way to convert from YCbCr to HSV. Saturation is sqrt(Cb^2 + Cr^2). Now here is my issue. If I take pure red (1,0,0), green(0,1,0), and blue(0,0,1) colors, convert them to YCrCb, and then compute saturation, I do not get 1. Infact, all the saturations are different no matter which matrix I use for RGB to YCrCb conversion. Am I missing something?

$\endgroup$
1
$\begingroup$

Think about it this way. To calculate YCbCr of (1, 0, 0), you'll end up with Y = 0.299, Cb = -0.16873, Cr = 0.5. If you take the magnitude of the chroma channels (sqrt(Cb*Cb + Cr*Cr)), you get ~0.53 for the "saturation". The YCbCr color space has a different shape than RGB, so it may represent values differently enough that you don't get the exact same answer in both cases. Furthermore, our perception of luminance and saturation is not consistent among colors.

If all you want is to calculate the saturation of an RGB component, it can be calculated by:

float saturation = max(r, g, b) - min(r, g, b);

Note that if you attempt to calculate perceptually uniform amounts of color saturation you end up with systems like the Munsell Color System where the shape of the color space is highly irregular compared with the cubes and cylinders of other color spaces.

If you tell us what you're trying to achieve, we might be able to offer an actual solution to whatever the problem is.

$\endgroup$
  • $\begingroup$ Thank you for the answer. Well, I was trying to compute hue and saturation from Cb and Cr values. I read hue = atan2(Cr/Cb) and saturation is sqrt(Cr^2+ Cb^2). Saturation I see is nearly 0.5. Same for hue, for Red color it turns out to be 108 degrees when measured from X axis or 18 degrees when measured along Y-axis anticlockwise. Not 0 in any case. $\endgroup$ – Deepak Sharma May 31 '18 at 8:08

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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