setmemorymax(512) setmtmode(5,6) raw=ImageSource("raw.png",start=0,end=0) gdapt=ImageSource("gdapt.png",start=0,end=0) setmtmode(2,6) #################################### raw RatioResize(320.0,"adjust2w",kernel="point") r = ShowRed("YV12") g = ShowGreen("YV12") b = ShowBlue("YV12") interleave(r,g,b) raw=last #################################### uv = 3 sstr = 2.7 amnt = 255 uv2 = uv STR = string(sstr) AMN = string(amnt) clp=last vblur = clp.mt_convolution("50 99 50","1",U=uv,V=uv) hblur = clp.mt_convolution("1","50 99 50",U=uv,V=uv) masky = mt_luts (vblur, hblur, mode="avg", pixels=mt_circle(1)+string(0), expr="x y - abs 2 > 255 0 ?" ) vblur = mt_merge(clp,vblur,masky) # limiting to no less than pixel change of 13 to exclude faint checkerboard blur mt_lutxy(clp,vblur,"x y - abs 13 < x y ?") blurred=last #################################### gdapt RatioResize(320.0,"adjust2w",kernel="point") r = ShowRed("YV12") g = ShowGreen("YV12") b = ShowBlue("YV12") interleave(r,g,b) gdapt=last #################################### # get difference of both approaches mt_lutxy(blurred,gdapt," x y - abs",u=-128,v=-128) # ensure we always get the highest change regardless of plane mt_logic(mt_logic(SelectEvery (3, 0), SelectEvery (3, 1),"max"),SelectEvery (3, 2),"max") # cleaning 1px dots removegrain(1) # strengthen the mask mt_binarize(25,u=-128,v=-128) # sames as mt_lut(yexpr=" x 25 > 255 0 ?") # mix my original approach with source using the diff of gdapt/blurred as a mask mt_merge(raw,blurred,last.invert,luma=true) mergergb(SelectEvery (3, 0), SelectEvery (3, 1), SelectEvery (3, 2)) RatioResize(640.0,"adjust2w",kernel="point")