Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #################
- # #
- # CanDerainE #
- # By Cannonaire #
- # #
- # Ver. E.01 #
- # #
- # Updated: #
- # 2011-02-23 #
- # #
- #################
- #
- # Defaults:
- # CanDerainE(str=255 , dstr=30, thr=2.0, radius=10, rthr=90, mask=false)
- #
- #################
- function CanDerainE(clip clp0, int "str", int "dstr", float "thr", int "radius", float "rthr", bool "mask")
- {
- Assert(clp0.IsYUV(), "CanDerainbow: Input must be YUV")
- #Set defaults and split YUV
- str = default(str, 255)
- dstr = default(dstr, 30)
- thr = default(thr, 2.0)
- radius = default(radius, 10)
- rthr = default(rthr, 90)
- mask = default(mask, false)
- clpy0 = clp0.Greyscale()
- clpu0 = UtoY(clp0)
- clpv0 = VtoY(clp0)
- #Create masks
- emask = clpy0.tcanny(sigma = thr, mode = 0)
- \ .mt_inflate(thy = radius).mt_inflate(thy = radius).mt_inflate(thy = radius).mt_inflate(thy = radius).mt_inflate(thy = radius).mt_inflate(thy = radius).mt_inflate(thy = radius).mt_inflate(thy = radius).mt_inflate(thy = radius).mt_inflate(thy = radius)
- \ .mt_inflate(thy = radius).mt_inflate(thy = radius).mt_inflate(thy = radius).mt_inflate(thy = radius).mt_inflate(thy = radius).mt_inflate(thy = radius).mt_inflate(thy = radius).mt_inflate(thy = radius).mt_inflate(thy = radius).mt_inflate(thy = radius)
- \ .mt_binarize(threshold=rthr)
- #Create fixed chroma channels
- clp1 = clp0.Deen("a3d", 4, 0, dstr).tweak(sat=1.08)
- clp2 = overlay(clp0, clp1, mode = "blend", mask = emask, opacity=1)
- clpu2 = UtoY(clp2)
- clpv2 = VtoY(clp2)
- #Apply fixed chroma channels based on masks
- clpuf = overlay(clpu0, clpu2, mode = "blend", opacity = str/255.0)
- clpvf = overlay(clpv0, clpv2, mode = "blend", opacity = str/255.0)
- #Set final clip to be returned
- clpf = (mask) ? emask : YtoUV(clpuf, clpvf, clpy0)
- return clpf
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement