Convert YUV into HSL or HSV bypassing the RGB step

纵然是瞬间 提交于 2019-12-10 16:17:57

问题


Wikipedia and plethora of online resources provide detailed and abundant help with various color space conversions from/to RGB. What I need is a straight YUV->HSL/HSV conversion.

In fact what I need is just the Hue (don't care much for the Saturation or the brightness Lightness/Value). In other words I just need to calculate the "color angle" for a given YUV color.

Code in any language would suffice, though my preference is C-style syntax.

Note that by YUV I mean specifically Y′UV, a.k.a. YCbCr (if that makes any difference).


回答1:


While YUV->RGB colorspace conversion is linear (same as "can be expressed as a matrix operation") the RGB->HSL is not. Thus it is not possible to combine the two into a single operation.

Thank you Kel Solaar for confirming this for me.

For reference:

  • YUV(YCbCr)->RGB conversion
  • RGB->HSL conversion

Note that mathematically the calculation for Hue is written piecewise as the "base angle" depends on which sector the color is in and the "major color" is driven by the max(R, G, B) expression.



来源:https://stackoverflow.com/questions/46460225/convert-yuv-into-hsl-or-hsv-bypassing-the-rgb-step

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!