Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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")
- {
- # contra-sharpening: sharpen the denoised clip, but don't add more to any pixel than what was removed previously.
- # script function from Didee from the VERY GRAINY thread
- chroma = Default(chroma, false )
- preblur = Default(preblur, true )
- preblurc = Default(preblurc,preblur)
- preR = Default(preR, 1 )
- limit = Default(limit, true )
- RGmode = Default(RGmode, 11 )
- RGmodeU = Default(RGmodeU, RGmode )
- Repmode = Default(Repmode, 1 )
- RepmodeU = Default(RepmodeU,Repmode)
- s = preblur ? denoised.minblur(preR, preblurc ? 3 : 1) : denoised # Damp down remaining spots of the denoised clip.
- allD = mt_makediff(original, denoised, Y=3, U=chroma?3:1, V=chroma?3:1) # The difference achieved by the denoising.
- blured = Defined(blur) ? Eval("s."+blur) : s.removegrain(RGmode, chroma ? RGmodeU : -1)
- ssD = mt_makediff(s, blured, Y=3, U=chroma?3:1, V=chroma?3:1) # The difference of a simple kernel blur.
- ssDD = ssD.repair(allD, mode=Repmode, modeU=chroma?RepmodeU:-1) # Limit the difference to the max of what the denoising removed locally.
- 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.
- denoised.mt_adddiff(ssDD, Y=3, U=chroma?3:2, V=chroma?3:2) # Apply the limited difference. (Sharpening is just inverse blurring.)
- return last
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement