View Full Version : Gamma vs. saturation
Stormborec
28th January 2015, 17:34
In Levels "manual" stands:
"When processing data in YUV mode, Levels only gamma-corrects the luma information, not the chroma. Gamma correction is really an RGB concept, and I don't know how to do it properly in YUV ..."
If I understand - the only way to maintain saturation during gamma correction is to do it in RGB, otherwise the midtones - where is the biggest change - looses saturation according the gamma curve - if the value of gamma increases ...
StainlessS
28th January 2015, 21:14
Nobody knows how to do it properly in YUV, so I would not expect too many suggestions, as you say, it is a RGB concept.
If however you just want to mod in YUV then see ColorYUV2: http://forum.doom9.org/showthread.php?t=156774&highlight=coloryuv2
Stormborec
28th January 2015, 22:24
Can coloryuv2 does something like this? :
y = converttoy8()
u = utoy8()
v = vtoy8()
y_scaled = y.bilinearresize(width(u), height(u))
u_adjusted = mt_lutxy(u,y_scaled,expr="x 128 - 1.10 * 128 + y 16 - 0.06918 * +")
v_adjusted = mt_lutxy(v,y_scaled,expr="x 128 - 1.30 * 128 + y 16 - 0.02525 * -")
ytouv(u_adjusted,v_adjusted,y)
Stormborec
29th January 2015, 18:37
Maybe something like: would do the job concerning gamma without saturation shift
y = converttoy8()
u = utoy8()
v = vtoy8()
y_adjusted = mt_lut("x 16 - 219 / 1 1.2 / ^ 219 * 16 +", chroma="copy")
y_scaled = y.bilinearresize(width(u),height(u))
u_adjusted = mt_lutxy(u,y_scaled,"x 128 - y 16 - 219 / 1 1.2 / ^ 219 * 16 + y / * 128 +")
v_adjusted = mt_lutxy(v,y_scaled,"x 128 - y 16 - 219 / 1 1.2 / ^ 219 * 16 + y / * 128 +")
ytouv(u_adjusted,v_adjusted,y_adjusted)
NOW IT WORKS, YES, NOW IT WORKS, perhaps ... :D
There could be: y_scaled = y_adjusted.bilinearresize(width(u),height(u))
but I don't know, if is it correct to chain the luts ...
Or exactly like this:
u_adjusted = mt_lutxy(u,y_scaled,"x 128 - y 16 - 219 / 1 1.2 / ^ 219 * y 16 - / * 128 +")
v_adjusted = mt_lutxy(v,y_scaled,"x 128 - y 16 - 219 / 1 1.2 / ^ 219 * y 16 - / * 128 +")
(excepting the zero division, when black ... maybe diddle it ... y 15 -
vBulletin® v3.8.11, Copyright ©2000-2026, vBulletin Solutions Inc.