Log in

View Full Version : maskHS: Hue interval reference point?


belonesox
26th August 2010, 09:55
I looked at description of MaskHS (http://avisynth.org/mediawiki/MaskHS) and see strange hue intevals in samples, which is incompatible with http://en.wikipedia.org/wiki/Hue:

"Orange" — maskHS hue → 105:138, Wikipedia → 30:60
"Blue" — maskHS hue → 345:359, Wikipedia → 200:220


WTF?

Thanks all in advance,
Sincerely, Stas Fomin

IanB
26th August 2010, 14:15
Different implementations of the "Hue" concept.

AVSHue = 180 * atan2((V-128), (U-128)) / PI

belonesox
26th August 2010, 15:42
Thank you!

But all "Hues" in all graphic editors are consistent with WikiHue.

Could you provide formula f

AVSHue = f(WikiHue)

?

IanB
26th August 2010, 23:03
Kr = Rec601 ? 0.299 : 0.2125
Kg = Rec601 ? 0.587 : 0.7154
Kb = Rec601 ? 0.114 : 0.0721

[r, g, b] = HSLtoRGB(WikiHue, 1.0, 1.0)

v = r - g * Kg/(1-Kr) - b * Kb/(1-Kr)
u = - r * Kr/(1-Kb) - g * Kg/(1-Kb) + b

AVSHue = 180 * atan2(v, u) / PiI will leave it as an exercise to reverse the RGB to Hue formula on the Wiki page into a HSLtoRGB() function, hint assume 1.0 Saturation and 1.0 Lightness.