SHARE
TWEET

ContraSharpen.avsi

mawen1250 Jun 9th, 2012 239 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Function ContraSharpen(clip denoised, clip original, bool "chroma", bool "preblur", bool "preblurc", int "preR", bool "limit", string "blur", int "RGmode", int "RGmodeU", int "Repmode", int "RepmodeU")
  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.  
  6. chroma   = Default(chroma,  false  )
  7. preblur  = Default(preblur, true   )
  8. preblurc = Default(preblurc,preblur)
  9. preR     = Default(preR,    1      )
  10. limit    = Default(limit,   true   )
  11. RGmode   = Default(RGmode,  11     )
  12. RGmodeU  = Default(RGmodeU, RGmode )
  13. Repmode  = Default(Repmode, 1      )
  14. RepmodeU = Default(RepmodeU,Repmode)
  15.  
  16. s      = preblur ? denoised.minblur(preR, preblurc ? 3 : 1) : denoised # Damp down remaining spots of the denoised clip.
  17. allD   = mt_makediff(original, denoised, Y=3, U=chroma?3:1, V=chroma?3:1) # The difference achieved by the denoising.
  18. blured = Defined(blur) ? Eval("s."+blur) : s.removegrain(RGmode, chroma ? RGmodeU : -1)
  19. ssD    = mt_makediff(s, blured, Y=3, U=chroma?3:1, V=chroma?3:1) # The difference of a simple kernel blur.
  20. ssDD   = ssD.repair(allD, mode=Repmode, modeU=chroma?RepmodeU:-1) # Limit the difference to the max of what the denoising removed locally.
  21. ssDD   = limit ? ssDD.mt_lutxy(ssD, "x 128 - abs y 128 - abs < x y ?", Y=3, U=chroma?3:1, V=chroma?3:1) : ssDD # abs(diff) after limiting may not be bigger than before.
  22.  
  23. denoised.mt_adddiff(ssDD, Y=3, U=chroma?3:2, V=chroma?3:2) # Apply the limited difference. (Sharpening is just inverse blurring.)
  24.  
  25. return last
  26. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top