Advertisement
Guest User

CanDerainE1

a guest
Feb 23rd, 2011
284
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #################
  2. #               #
  3. #  CanDerainE   #
  4. # By Cannonaire #
  5. #               #
  6. #   Ver. E.01   #
  7. #               #
  8. #   Updated:    #
  9. #  2011-02-23   #
  10. #               #
  11. #################
  12. #
  13. # Defaults:
  14. # CanDerainE(str=255 , dstr=30, thr=2.0, radius=10, rthr=90, mask=false)
  15. #
  16. #################
  17.  
  18. function CanDerainE(clip clp0, int "str", int "dstr", float "thr", int "radius", float "rthr", bool "mask")
  19. {
  20. Assert(clp0.IsYUV(), "CanDerainbow: Input must be YUV")
  21.  
  22. #Set defaults and split YUV
  23. str     =   default(str, 255)
  24. dstr    =   default(dstr, 30)
  25. thr     =   default(thr, 2.0)
  26. radius  =   default(radius, 10)
  27. rthr    =   default(rthr, 90)
  28. mask    =   default(mask, false)
  29.  
  30. clpy0   =   clp0.Greyscale()
  31. clpu0   =   UtoY(clp0)
  32. clpv0   =   VtoY(clp0)
  33.  
  34. #Create masks
  35. emask   =   clpy0.tcanny(sigma = thr, mode = 0)
  36.         \   .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)
  37.         \   .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)
  38.         \   .mt_binarize(threshold=rthr)
  39.        
  40. #Create fixed chroma channels
  41. clp1    =   clp0.Deen("a3d", 4, 0, dstr).tweak(sat=1.08)
  42. clp2    =   overlay(clp0, clp1, mode = "blend", mask = emask, opacity=1)
  43. clpu2   =   UtoY(clp2)
  44. clpv2   =   VtoY(clp2)
  45.  
  46. #Apply fixed chroma channels based on masks
  47. clpuf   =   overlay(clpu0, clpu2, mode = "blend", opacity = str/255.0)
  48. clpvf   =   overlay(clpv0, clpv2, mode = "blend", opacity = str/255.0)
  49.  
  50. #Set final clip to be returned
  51. clpf    =   (mask)  ?   emask : YtoUV(clpuf, clpvf, clpy0)
  52.  
  53. return clpf
  54. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement