YARK source

From Avisynth wiki
Revision as of 01:05, 14 December 2015 by Raffriff42 (Talk | contribs)

Jump to: navigation, search

source: http://pastebin.com/sfDZ00rx

# Yet Another Rainbow Killer - jase99
# based on mfRainbow v0.31, chubbyrain2, various other doom9 posts
# http://forum.doom9.org/showthread.php?t=141165
function YARK(clip c, int "thr", int "rad", int "str", int "scd", bool "show") {
  thr  = default(thr, 10)    # threshold as per ChubbyRain2
  rad  = default(rad, 2)     # temporal smoothing radius as per mfRainbow
  str  = default(str, 25)    # temporal smoothing strength as per mfRainbow
  scd  = default(scd, 2)     # scene change detection strength as per mfRainbow
  show = default(show, false)

  u = c.UToY()
  v = c.VToY()

  uc = u.mt_convolution(horizontal="1", vertical="1 -2 1", Y=3, U=0, V=0)
  vc = v.mt_convolution(horizontal="1", vertical="1 -2 1", Y=3, U=0, V=0)
  mt_lutxy(uc, vc, Yexpr = string("x y + " + string(thr) + " > 256 0 ?"))
  PointResize(c.width, c.height)
  mt_expand(Y=3, U=-128, V=-128)
  uvcmask = Blur(1.5)

  c.UnsharpMask(200).UnsharpMask(200)
  mt_edge(thY1=3, thY2=255, thC1=255, thC2=255, mode="roberts", Y=3, V=1, U=1)
  mt_deflate().Levels(0, 1.0, 45, 0, 255).Blur(1.0)
  mt_deflate().Levels(0, 1.0, 75, 0, 255)
  mt_deflate().mt_deflate().mt_deflate()
  ymask = Greyscale()

  u.Unsharpmask(500).Unsharpmask(500)
  mt_edge(thY1=3, thY2=255, thC1=255, thC2=255, mode="roberts", Y=3, V=1, U=1)
  Levels(0, 1.0, 100, 0, 255)
  Greyscale()
  umask = LanczosResize(c.width, c.height)
 
  v.Unsharpmask(500).Unsharpmask(500)
  mt_edge(thY1=3, thY2=255, thC1=255, thC2=255, mode="roberts", Y=3, V=1, U=1)
  Levels(0, 1.0, 75, 50, 255)
  Greyscale()
  vmask = LanczosResize(c.width, c.height)

  Overlay(ymask,  umask, mode="lighten")
  Overlay(vmask, mode="hardlight")
  mt_inflate().mt_inflate()
  Levels(0, 1, 100, 0, 255, false)
  yuvmask = Greyscale()

  Overlay(yuvmask, uvcmask, mode="lighten")
  mask = LanczosResize(u.width, u.height)

  derainu = u.TemporalSoften(rad, str, 1, scd, 2)
  derainv = v.TemporalSoften(rad, str, 1, scd, 2)

  derainmasku = mt_merge(u, derainu, mask, Y=3, U=1, V=1)
  derainmaskv = mt_merge(v, derainv, mask, Y=3, U=1, V=1)

  c.Overlay(c.blankclip(color=$0000FF), mask=yuvmask)
  visual = Overlay(c.blankclip(color=$00FF00), mask=uvcmask)

  show == false ?  c.MergeChroma(YToUV(derainmasku, derainmaskv, c.Greyscale())) : visual
}