Advertisement
tophf

fix_qtec_drawing

Mar 28th, 2015
536
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function fix_qtec_drawing( clip c ) {
  2.     function linemask( clip c, int "blur", int "thresh", int "str" )
  3.     {
  4.         blur=default(blur,5)
  5.         thresh=default(thresh,4)
  6.         str=default(str,16)
  7.         mt_lutxy(c,c.binomialblur(blur,u=1,v=1),"x "+string(thresh)+" + y < y x - "+string(str)+" * 0 ?")
  8.     }
  9.     function YAHR2( clip clp, int "warpdepth" )
  10.     {# Y'et A'nother H'alo R'educing script
  11.         warpdepth=default(warpdepth,32)
  12.         b1    = clp.minblur(2,2).removegrain(11,-1)
  13.         b1D   = mt_makediff(clp,b1)
  14.         w1    = clp.aWarpSharp2(depth=warpdepth,blur=2,chroma=1)
  15.         w1b1  = w1.minblur(2,1).removegrain(11,-1)
  16.         w1b1D = mt_makediff(w1,w1b1)
  17.         DD    = b1D.repair(w1b1D,13,-1)
  18.         DD2   = mt_makediff(b1D,DD)
  19.         clp.mt_makediff(DD2,U=2,V=2)
  20.     }
  21.     function YAHRmask(clip c, int "expand", int "warpdepth")
  22.     {
  23.         c
  24.         expand=default(expand,5)
  25.         warpdepth=default(warpdepth,32)
  26.         vEdge=mt_lutxy(mt_expand.mt_expand,"x y - abs 8 - 7 <<")
  27.         mt_merge(yahr2(warpdepth),\
  28.             vEdge.binomialblur(expand*2,u=1,v=1).mt_lut("x 16 *").mt_logic(vEdge.removegrain(12,-1).mt_invert,"min"),\
  29.             u=2,v=2)
  30.     }
  31.     c
  32.     m=linemask()
  33.     # select dark blurs near line joints and corners
  34.     m2=m.binomialblur(1,u=1,v=1).mt_lut("x 16 *").binomialblur(1,u=1,v=1).mt_lut("x 200 - 4 *").mt_logic(m.mt_invert,"min").removegrain(12,-1).mt_lut("x 64 - 4 *").tmaskcleaner(10).mt_expand.mt_expand.mt_logic(m.mt_expand,"max").removegrain(20,-1).removegrain(20,-1)
  35.     # lighten them
  36.     vBlur=binomialblur(2,u=1,v=1)
  37.     mt_merge(mt_lutxy(vBlur,"y x < x x y - 32 * + x ?"),m2,u=1,v=1).mt_clamp(binomialblur(10,u=1,v=1),last,100,0)
  38.     # separate close lines
  39.     debilinear(960,540).nnedi3_rpow2(2,cshift="spline36resize")
  40.     # darken whites near line corners and joints
  41.     mt_merge(mt_lutxy(binomialblur(4,u=1,v=1),"y x < x y - 4 / y + x ?"),m.mt_expand.mt_expand.binomialblur(3,u=1,v=1),u=1,v=1)
  42.  
  43.     dehalo_alpha_mt_y8(3,3,0,1).mt_merge(last,m2,u=1,v=1) #don't make inter-line joints and corners darker
  44.     yahrmask
  45.     mt_merge(blankclip(last,160,90,color_yuv=$808080).addgrainC(100,constant=true,0).bicubicresize(width,height).mt_lut("x 128 - 255 * 128 +").mt_adddiff(last),m,u=1,v=1).mt_clamp(last,vBlur,0,50,u=1,v=1)
  46.     aasw
  47.  
  48.     mt_merge(c,mt_lut("255 x 64 - 0 max 256 128 - / 3 ^ 256 * -").mt_inpand.tmaskcleaner(300).mt_expand.mt_expand.mt_expand.mt_expand.binomialblur(3,u=1,v=1),u=1,v=1)
  49.     mergechroma(c)
  50. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement