Welcome to Doom9's Forum, THE in-place to be for everyone interested in DVD conversion. Before you start posting please read the forum rules. By posting to this forum you agree to abide by the rules. |
28th December 2014, 11:45 | #1 | Link |
Registered User
Join Date: Feb 2013
Posts: 161
|
Something like RGBAdjust but in YUV
RGBAdjust:
rb, gb, bb "OFFSETS rb, gb, bb - add a value to the red, green, blue" (the same could be done in coloryuv - in YUV) r, g, b "red (/green/blue) is scaled. For example, a scale of 3.0 MULTIPLIES the red channel of each pixel by 3" - I doubt it would go something like this done in YUV, but I mean something else ... The third, which isn't yet possible in RGB nor in YUV is: OFFSET of chroma, but with values multiplied by level of LUMA of each pixel black - no shift white - max shift Exists the WhiteBalance plugin, but it is relatively inaccurate - changing some value only by 1 step do big color change ... |
28th December 2014, 13:41 | #2 | Link |
Registered User
Join Date: Mar 2014
Posts: 308
|
Even if there's no currently existing filter to do exactly what you want, it's not hard to throw something together using Masktools.
Code:
source y = converttoy8() u = utoy8() v = vtoy8() y_adjusted = mt_lut(y,expr="x") u_adjusted = mt_lutxy(u,y,expr="x y 16 - 0.1 * +") v_adjusted = mt_lutxy(v,y,expr="x y 16 - 0.1 * +") ytouv(u_adjusted,v_adjusted,y_adjusted) # note that the order here is U, V, Y
__________________
Say no to AviSynth 2.5.8 and DirectShowSource! |
28th December 2014, 15:33 | #3 | Link | |
HeartlessS Usurer
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
|
Quote:
int gain_y = 0 is same as usual float gain=1.0 (no change) int gain_y = 256 is same as usual float gain=2.0 int gain_y = 512 is same as usual float gain=3.0 int gain_y = -256 is same as usual float gain=0.5 See ColorYUV docs. EDIT: Cont_u=256 : Cont_v=256 : Same as Saturation * 2.0 ColorYUV2(), also has SPow (S shaped power curve) as well as RPow (As gamma). ColorYUV2 here: http://forum.doom9.org/showthread.ph...ight=coloryuv2
__________________
I sometimes post sober. StainlessS@MediaFire ::: AND/OR ::: StainlessS@SendSpace "Some infinities are bigger than other infinities", but how many of them are infinitely bigger ??? Last edited by StainlessS; 28th December 2014 at 16:22. |
|
28th December 2014, 19:29 | #4 | Link |
Registered User
Join Date: Feb 2013
Posts: 161
|
colours:
many thanks I had in mind masktools, but the strange writing of its functions will be forever a secret for me Could you describe, what the script actually do? I'm going to test it ... StainlessS: I am surprised that until now I have not come across your Coloryuv2 ... The gain in ColorYUV is analogy of contrast in Tweak. For chroma it is useless, because of the strange chroma waveform. Every parameter in this basic internal functions is independent of the others. |
28th December 2014, 19:38 | #5 | Link | |
Registered User
Join Date: Mar 2012
Location: Texas
Posts: 1,664
|
Quote:
|
|
28th December 2014, 19:39 | #6 | Link |
Registered User
Join Date: Feb 2013
Posts: 161
|
y = converttoy8() # ... creating "y clip" without chroma from "last"
u = utoy8() # ... creating "u clip" without chroma with values from chroma u in "last" v = vtoy8() # ... creating "v clip" without chroma with values from chroma v in "last" y_adjusted = mt_lut(y,expr="x") # ... crating some mask from luma of "last" ??? u_adjusted = mt_lutxy(u,y,expr="x y 16 - 0.1 * +") # ... some aplication of the mask on "chroma u" ??? v_adjusted = mt_lutxy(v,y,expr="x y 16 - 0.1 * +") # ... some aplication of the mask on "chroma v" ??? ytouv(u_adjusted,v_adjusted,y_adjusted) # ... gluing back together ??? |
28th December 2014, 19:51 | #9 | Link |
Registered User
Join Date: Mar 2012
Location: Texas
Posts: 1,664
|
@Stormborec
This is what I mean: Code:
y = converttoy8() u = utoy8() v = vtoy8() y_scaled = y.bicubicresize(width(u), height(u)) y_adjusted = mt_lut(y,expr="x") u_adjusted = mt_lutxy(u,y_scaled,expr="x y 16 - 0.1 * +") v_adjusted = mt_lutxy(v,y_scaled,expr="x y 16 - 0.1 * +") ytouv(u_adjusted,v_adjusted,y_adjusted) # note that the order here is U, V, Y |
28th December 2014, 20:39 | #13 | Link |
Registered User
Join Date: Feb 2013
Posts: 161
|
Many thanks !!!
BlankClip(length=1,width=640,height=360,fps=25,pixel_type="yv12",color=$ffffff) levels(0,1,255,0,235) y = converttoy8() u = utoy8() v = vtoy8() y_scaled = y.bicubicresize(width(u), height(u)) y_adjusted = mt_lut(y,expr="x") u_adjusted = mt_lutxy(u,y_scaled,expr="x y 16 - 0.05 * +") v_adjusted = mt_lutxy(v,y_scaled,expr="x y 16 - 0.0 * +") a = ytouv(u_adjusted,v_adjusted,y_adjusted) interleave(a,last) converttorgb.rgbadjust(analyze=true) #coloryuv(analyze=true) I've tested different colors and it works exactly as I wanted |
28th December 2014, 21:43 | #14 | Link |
Registered User
Join Date: Feb 2013
Posts: 161
|
I made from your code a function:
Code:
function Colorsbyy( clip last, float "ou", float "ov" ) { ou = default(ou/219, 0.0) ov = default(ov/219, 0.0) y = converttoy8() u = utoy8() v = vtoy8() y_scaled = y.bilinearresize(width(u), height(u)) y_adjusted = mt_lut(y,expr="x") u_adjusted = mt_lutxy(u,y_scaled,expr="x y 16 - "+string(ou)+" * +") v_adjusted = mt_lutxy(v,y_scaled,expr="x y 16 - "+string(ov)+" * +") ytouv(u_adjusted,v_adjusted,y_adjusted) return last } I added: /219, in order to the output looked - when input is a monochromatic image with luma = 235 - same like by using coloryuv(off_u, off_v). I'll still test different resizers ... So I tested spline36resize vs. bilinearresize - by using coloryuv(analyze=true) - there is a "one or two number" change, but it isn't a chance to see the change, although I sharpened, brightened and enlarged the image 3× ... spline36resize vs. bilinearresize - the speed is about 3 % higher for bilinear ... Last edited by Stormborec; 28th December 2014 at 23:42. |
28th December 2014, 23:57 | #15 | Link |
Moderator
Join Date: Nov 2001
Location: Netherlands
Posts: 6,364
|
Do you guys never use the cont_u and cont_v arguments of ColorYUV? It stretches the chroma channels from the center:
it stretches the signal out from the center. That means that if the contrast is set to 0, it preserves the values as they are. When the contrast is 256 all values are multiplied by 2 (twice as bright). If the contrast is 512 all values are multiplied by 3. Thus if cont = k*256 for some integer k (and zero gain) then Y becomes Y + k*(Y-128) (idem for the chroma). Although it is possible, it doesn't make sense to apply this setting to the luma of the signal. So setting cont_u = 512 (=2*256) means that U becomes: U_new = U_old + 2*(U_old-128). You need to set opt=coring to clamp the values to tv-levels. Or isn't this what you want? @Reel.Deel, What are you trying to do in your script above? My polish is very bad, but i guess i need to read it as follows: // u_adjusted = mt_lutxy(u,y_scaled,expr="x y 16 - 0.1 * +") u_adjusted = 0.1 * (16 - y_scaled) + u Doesn't make much sense to me, but perhaps i completely misread it ... Why do you need a 2d lut table at all? Last edited by Wilbert; 29th December 2014 at 00:20. |
29th December 2014, 00:02 | #16 | Link |
Anime addict
Join Date: Feb 2009
Location: Spain
Posts: 673
|
SmoothAdjust works fine (16 bitdepth), you can try it.
http://forum.doom9.org/showthread.php?t=154971
__________________
Intel i7-6700K + Noctua NH-D15 + Z170A XPower G. Titanium + Kingston HyperX Savage DDR4 2x8GB + Radeon RX580 8GB DDR5 + ADATA SX8200 Pro 1 TB + Antec EDG750 80 Plus Gold Mod + Corsair 780T Graphite |
29th December 2014, 01:11 | #17 | Link | |
Registered User
Join Date: Mar 2012
Location: Texas
Posts: 1,664
|
colours (post #2) came up with this, I just added a small change.
Quote:
mt_infix("x y 16 - 0.1 * +") returns this: x+((y-16)*0.1) |
|
29th December 2014, 04:29 | #18 | Link | |
HeartlessS Usurer
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
|
Quote:
__________________
I sometimes post sober. StainlessS@MediaFire ::: AND/OR ::: StainlessS@SendSpace "Some infinities are bigger than other infinities", but how many of them are infinitely bigger ??? |
|
29th December 2014, 04:59 | #19 | Link |
Registered User
Join Date: Feb 2013
Posts: 161
|
SmoothAdjust is just other very very slow overkill for me
I know cont_u, cont_v very well. It's equivalent for saturation if it is used both ones. OT.: BlankClip(length=125,width=640,height=360,fps=25,pixel_type="yv12",color=$0000e2) coloryuv(analyze=true) => y=38 ; u=227 ; v=112 ; r=0 ; g=0 ; b=225 BlankClip(length=125,width=640,height=360,fps=25,pixel_type="yv12",color=$0000ff) coloryuv(off_y=-25) coloryuv(analyze=true) => y=16 ; u=240 ; v=110 ; r=0 ; g=0 ; b=226 The color is nearly the same. So what does the big different in yuv mean? Am I dreaming or awake ??? |
29th December 2014, 05:14 | #20 | Link |
I'm Siri
Join Date: Oct 2012
Location: void
Posts: 2,633
|
why do you just have to adjust colors under yuv colorspace?
if ur clip is ycbcr you can see y as green (obviously not actual green tho) u as blue (not actual blue also) v as red let's say you wanna enhance blue a little bit mt_lut ("x 128 > x 128 - 1.24 * 128 + x 128 - 0.72 * 128 + ?", y=2, u=3, v=2) might help # ((x > 128) ? (x - 128) * 1.24 + 128 : (x - 128) * 0.72 + 128) Last edited by feisty2; 29th December 2014 at 05:17. |
Thread Tools | Search this Thread |
Display Modes | |
|
|