# http://forum.doom9.org/showthread.php?p=1530964#post1530964 #Input ................................................................................................ Directshowsource("J:\test\testclip König Drosselbart.avi").killaudio().converttoYV12.tdeint() #SmoothGradationRGB ................................................................................................ # SmoothGradationRGB is a 5 point gradation curve in RGB color space # It is a 5-point Gradiation Curve Lo - P0 - Mid - P1 - Hi with global adjustments for Point 0, Mid and Point 1 and R,G,B offsets for each point. # Free adjustment of position (distance from top or bottom line) and RGB offset for P0 and P1. # You can see all 3 curves blendet into the Y curve diagram when ShowRGB=true # v0.5b curve need still a fix to adjust 0...2 and 253...255 loadplugin("J:\plugins\SmoothAdjust.dll") po1 = 228 #position of point 1, <253 because x=254 is used as first point for levels adjustment offs1 = 10 #shift of point 1 to left (darker) or right (brighter), adjust bright tones offs1R = 1 # Additional offset R for that point offs1G = 0 offs1B = 0 midRGB=0 # offset for Midpoint (128), shifts curve to the left or right, influences mid tones midR=0 # additional R offset for Mid (128) midG=0 midB=0 po0 = 37 #position of point 0, >2 because x=1 is used as first point for levels adjustment offs0 = -7 # shift of point 0 to left (darker) or right (brighter), adjust dark tones offs0R = 0 # additional R offset for point 0 offs0G = 0 offs0B = 0 HiR=254 # max level, will be scaled to value 254 HiG=254 HiB=254 LoR=1 #min level, will be scaled to 1 LoG=1 LoB=4 SmoothRGB=0 TVrange=0 #when input is TV range LimiterRGB=select(0,false,true) ShowRGB=select(1,false,true) #Show Gradation Curve and input-output comparision OutRGB=select(1,false,true) #1=RGB output, 2= Output conversion to YV12 debugRGB=0 #show input parameters for Scurve no/yes converttoRGB R = ShowRed(pixel_type="YV12") .Scurve(Lo=LoR, po0=po0, offs0=offs0+offs0R, mid=midRGB+midR, po1=po1, offs1=offs1+offs1R, Hi=HiR, limiter=limiterRGB,Show=showRGB,TVrange=TVrange, Smooth=SmoothRGB, debug=debugRGB) G = ShowGreen(pixel_type="YV12") .Scurve(Lo=LoG, po0=po0, offs0=offs0+offs0G, mid=midRGB+midG, po1=po1, offs1=offs1+offs1G, Hi=HiG, limiter=limiterRGB,Show=showRGB,TVrange=TVrange, Smooth=SmoothRGB,debug=debugRGB*20) B = ShowBlue(pixel_type="YV12") .Scurve(Lo=LoB, po0=po0, offs0=offs0+offs0B, mid=midRGB+midB, po1=po1, offs1=offs1+offs1B, Hi=HiB,limiter=limiterRGB,Show=showRGB,TVrange=TVrange, Smooth=SmoothRGB, debug=debugRGB*40) last=MergeRGB(R,G,B) last= (OutRGB==true) ? last : last.ConvertToYv12() return last#.info() function Scurve(clip "clip", int "Lo", int "po0", int "offs0", int "mid", int "po1", int "offs1", int "Hi", bool "show", bool "limiter", int "TVrange", int "smooth", int "debug") { # interp=2 bicubic interpolation default po0 = default(po0, 24) # Point 0 dark position offs0 = default(offs0, 0) po1 = default(po1, 230) # Point 1 bright position offs1 = default(offs1, 0) Lo = default(Lo, 1) # Lo point offset = all inputs below will be transformed to 0 mid = default(mid, 0) # shift of mid point (128) to dark/lights Hi = default(Hi, 1) # high point offset = all inputs above will be transformed to 255 show = default(show, false) # show curve limiter = default(limiter, false) # clamp to tv levels x0=string(po0) y0=string( Correct255(po0+offs0, Lo, 128+mid) ) x1=string(po1) y1=string( Correct255(po1+offs1, 128+mid, Hi) ) debug = default(debug, 0) # 0= no info, >0 y shift for information in pixels last= clip.SmoothCurve(Ycurve="0-0; "+string(Lo)+"-1; "+string(y0)+"-"+string(x0)+"; "+string(128+mid)+"-128; " + string(y1)+ "-" +string(x1)+"; "+string(Hi)+"-254; 255-255"\ ,Limiter=limiter,show=show,TVrange=TVrange, smooth=smooth) last = (debug>0) ? last.subtitle(y=debug, "0-0; "+string(Lo)+"-1; "+string(y0)+"-"+string(x0)+"; "+string(128+mid)+"-128; " + string(y1)+ "-" +string(x1)+"; "+string(Hi)+"-254; 255-255" ) : last return last } function Correct255(int in, int pre, int post) { pre = default(pre, 2) post = default(post, 253) o= (in >253) ? 253: in # max value is 255 o= (o <2) ? 2: o #min value is 0 o= (o > pre) ? o: pre+1 #must be greater than previous reference point of gradation curve o= (o < post) ? o: post-1 #must be smaller than next reference point of gradation curve return o } ### AvsP marked script ### # # http://forum.doom9.org/showthread.php?p=1530964#post1530964 # #Input ................................................................................................ # Directshowsource("J:\test\testclip König Drosselbart.avi").killaudio().converttoYV12.tdeint() # # #SmoothGradationRGB ................................................................................................ # # SmoothGradationRGB is a 5 point gradation curve in RGB color space # # It is a 5-point Gradiation Curve Lo - P0 - Mid - P1 - Hi with global adjustments for Point 0, Mid and Point 1 and R,G,B offsets for each point. # # Free adjustment of position (distance from top or bottom line) and RGB offset for P0 and P1. # # You can see all 3 curves blendet into the Y curve diagram when ShowRGB=true # # v0.5b # # loadplugin("J:\plugins\SmoothAdjust.dll") # # [] # po1 = [<"Point 1 lights", 180, 253, 228>] #position of point 1, <253 because x=254 is used as first point for levels adjustment # offs1 = [<"Offset 1 (2)", -32, 32, 10>] #shift of point 1 to left (darker) or right (brighter), adjust bright tones # offs1R = [<"Offset 1R (2)", -32, 32, 1>] # Additional offset R for that point # offs1G = [<"Offset 1G (2)", -32, 32, 0>] # offs1B = [<"Offset 1B (2)", -32, 32, 0>] # # midRGB=[<"MidRGB (0)", -64, 64, 0>] # offset for Midpoint (128), shifts curve to the left or right, influences mid tones # midR=[<"MidR (0)", -64, 64, 0>] # additional R offset for Mid (128) # midG=[<"MidG (0)", -64, 64, 0>] # midB=[<"MidB (0)", -64, 64, 0>] # # po0 = [<"Point 0 dark (8)", 2, 75, 37>] #position of point 0, >2 because x=1 is used as first point for levels adjustment # offs0 = [<"Offset 0 (2)", -32, 32, -7>] # shift of point 0 to left (darker) or right (brighter), adjust dark tones # offs0R = [<"Offset 0R (0)", -32, 32, 0>] # additional R offset for point 0 # offs0G = [<"Offset 0G (2)", -32, 32, 0>] # offs0B = [<"Offset 0B (2)", -32, 32, 0>] # # HiR=[<"HiR (255)", 222, 254, 254>] # max level, will be scaled to value 254 # HiG=[<"HiG (255)", 222, 254, 254>] # HiB=[<"HiB (255)", 222, 254, 254>] # LoR=[<"LoR (0)", 1, 32, 1>] #min level, will be scaled to 1 # LoG=[<"LoG (0)", 1, 32, 1>] # LoB=[<"LoB (0)", 1, 32, 4>] # # SmoothRGB=[<"SmoothRGB (100)", 0, 200, 0>] # # TVrange=[<"InputTVrangeRGB (0)", 0, 2, 0>] #when input is TV range # LimiterRGB=select([<"LimiterRGBout (0)", 0, 1, 0>],false,true) # ShowRGB=select([<"Show RGBCurve (0)", 0, 1, 1>],false,true) #Show Gradation Curve and input-output comparision # OutRGB=select([<"RGB out (on)", 0, 1, 1>],false,true) #1=RGB output, 2= Output conversion to YV12 # # debugRGB=[<"DebugRGB (0)", 0, 1, 0>] #show input parameters for Scurve no/yes # # converttoRGB # # R = ShowRed(pixel_type="YV12") .Scurve(Lo=LoR, po0=po0, offs0=offs0+offs0R, mid=midRGB+midR, po1=po1, offs1=offs1+offs1R, Hi=HiR, limiter=limiterRGB,Show=showRGB,TVrange=TVrange, Smooth=SmoothRGB, debug=debugRGB) # G = ShowGreen(pixel_type="YV12") .Scurve(Lo=LoG, po0=po0, offs0=offs0+offs0G, mid=midRGB+midG, po1=po1, offs1=offs1+offs1G, Hi=HiG, limiter=limiterRGB,Show=showRGB,TVrange=TVrange, Smooth=SmoothRGB,debug=debugRGB*20) # B = ShowBlue(pixel_type="YV12") .Scurve(Lo=LoB, po0=po0, offs0=offs0+offs0B, mid=midRGB+midB, po1=po1, offs1=offs1+offs1B, Hi=HiB,limiter=limiterRGB,Show=showRGB,TVrange=TVrange, Smooth=SmoothRGB, debug=debugRGB*40) # # last=MergeRGB(R,G,B) # # last= (OutRGB==true) ? last : last.ConvertToYv12() # return last#.info() # # # function Scurve(clip "clip", int "Lo", int "po0", int "offs0", int "mid", int "po1", int "offs1", int "Hi", bool "show", bool "limiter", int "TVrange", int "smooth", int "debug") # { # # interp=2 bicubic interpolation default # po0 = default(po0, 24) # Point 0 dark position # offs0 = default(offs0, 0) # po1 = default(po1, 230) # Point 1 bright position # offs1 = default(offs1, 0) # Lo = default(Lo, 1) # Lo point offset = all inputs below will be transformed to 0 # mid = default(mid, 0) # shift of mid point (128) to dark/lights # Hi = default(Hi, 1) # high point offset = all inputs above will be transformed to 255 # # show = default(show, false) # show curve # limiter = default(limiter, false) # clamp to tv levels # # x0=string(po0) # y0=string( Correct255(po0+offs0, Lo, 128+mid) ) # x1=string(po1) # y1=string( Correct255(po1+offs1, 128+mid, Hi) ) # # debug = default(debug, 0) # 0= no info, >0 y shift for information in pixels # # last= clip.SmoothCurve(Ycurve="0-0; "+string(Lo)+"-1; "+string(y0)+"-"+string(x0)+"; "+string(128+mid)+"-128; " + string(y1)+ "-" +string(x1)+"; "+string(Hi)+"-254; 255-255"\ # ,Limiter=limiter,show=show,TVrange=TVrange, smooth=smooth) # # last = (debug>0) ? last.subtitle(y=debug, "0-0; "+string(Lo)+"-1; "+string(y0)+"-"+string(x0)+"; "+string(128+mid)+"-128; " + string(y1)+ "-" +string(x1)+"; "+string(Hi)+"-254; 255-255" ) : last # return last # } # # function Correct255(int in, int pre, int post) # { # pre = default(pre, 2) # post = default(post, 253) # # o= (in >253) ? 253: in # max value is 255 # o= (o <2) ? 2: o #min value is 0 # o= (o > pre) ? o: pre+1 #must be greater than previous reference point of gradation curve # o= (o < post) ? o: post-1 #must be smaller than next reference point of gradation curve # return o # } # # # ### AvsP marked script ###