Seedmanc

Contrasharpening_basic.avsi

Nov 27th, 2016
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. FUNCTION ContraSharpening(clip filtered, clip original)
  2. {
  3.   # contra-sharpening: sharpen the denoised clip, but don't add more to any pixel than what was removed previously.
  4.   # script function from Didee from the VERY GRAINY thread
  5.   s    = filtered.minblur(1,1)                # damp down remaining spots of the denoised clip
  6.   allD = mt_makediff(original,filtered)       # the difference achieved by the denoising
  7.   ssD  = mt_makediff(s,s.removegrain(11,-1))  # the difference of a simple kernel blur
  8.   ssDD = ssD.repair(allD,1)                   # limit the difference to the max of what the denoising removed locally.
  9.   ssDD = SSDD.mt_lutxy(ssD,"x 128 - abs y 128 - abs < x y ?") # abs(diff) after limiting may not be bigger than before.
  10.   RETURN (filtered.mt_adddiff(ssDD,U=2,V=2))  # apply the limited difference. (sharpening is just inverse blurring)
  11. }
  12.  
  13. FUNCTION MinBlur(clip input, int r, int "uv")
  14. {
  15.   # Taken from MCBob.avs:
  16.   uv   = default(uv,3)
  17.  
  18.   # process chroma if uv==3, otherwise just luma
  19.   uv2  = (uv==2) ? 1  : uv
  20.   rg4  = (uv==3) ? 4  : -1
  21.   rg11 = (uv==3) ? 11 : -1
  22.   rg20 = (uv==3) ? 20 : -1
  23.   medf = (uv==3) ? 1  : -200
  24.  
  25.   # make our blur clips, r controls amount ...keep the best blur pixel from each
  26.   RG11D = (r==1) ? mt_makediff(input,input.removegrain(11, rg11),U=uv2,V=uv2)
  27.    \    : (r==2) ? mt_makediff(input,input.removegrain(11,rg11).removegrain(20,rg20),U=uv2,V=uv2)
  28.    \    :          mt_makediff(input,input.removegrain(11,rg11).removegrain(20,rg20).removegrain(20,rg20),U=uv2,V=uv2)
  29.   RG4D  = (r==1) ? mt_makediff(input,input.removegrain(4,rg4),U=uv2,V=uv2)
  30.    \    : (r==2) ? mt_makediff(input,input.medianblur(2,2*medf,2*medf),U=uv2,V=uv2)
  31.    \    :          mt_makediff(input,input.medianblur(3,3*medf,3*medf),U=uv2,V=uv2)
  32.   DD    = mt_lutxy(RG11D,RG4D,"x 128 - y 128 - * 0 < 128 x 128 - abs y 128 - abs < x y ? ?",U=uv2,V=uv2)
  33.   RETURN (input.mt_makediff(DD,U=uv,V=uv))
  34. }
Add Comment
Please, Sign In to add comment