Guest User

FixChromaBleedingMod

a guest
Feb 6th, 2014
127
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. # FixChromaBleedingMod v1.1
  2.  
  3. Function FixChromaBleedingMod (clip input, int "Shift", float "thr", float "strength", bool "f") {
  4.  
  5.   Shift = default ( Shift,       -4 )
  6.   thr   = default ( thr,       4.0 )
  7.   stre = default ( strength,       0.8 )
  8.   f =  default ( f,       true )
  9.  
  10.   # prepare to work on the V channel and reduce to speed up and filter noise
  11.   areaf = input.tweak3(sat=thr).VtoY.ReduceBy2
  12.   area = input.tweak3(sat=thr).VtoY.Blur(1.5)
  13.  
  14.   # select and normalize both extremes of the scale
  15.   red = f ? areaf.Levels(255,1.0,255,255,0) : area.Levels(255,1.0,255,255,0)
  16.   blue = f ? areaf.Levels(0,1.0,0,0,255) : area.Levels(0,1.0,0,0,255)
  17.  
  18.   # merge both masks
  19.   mask = MergeLuma(red, blue, 0.5).Levels(250,1.0,250,255,0).mt_expand(mode="both", y=3,u=3,v=3).mt_inflate(y=3,u=3,v=3)
  20.  
  21.   # expand to cover beyond the bleeding areas and shift to compensate the resizing
  22.    mask = mask.mt_edge("0 0 0 1 0 0 0 0 0", 0,255,0,255).mt_edge("1 1 1 1 1 1 0 0 0", 0,255,0,255).mt_expand(mode="both", y=3,u=3,v=3).mt_inflate(y=3,u=3,v=3)
  23.  
  24.   # back to full size and binarize (also a trick to expand)
  25.   mask = mask.BilinearResize(Width(input),Height(input)).Levels(10,1.0,10,0,255).mt_expand(mode="both", y=3,u=3,v=3).mt_inflate(y=3,u=3,v=3)
  26.  
  27.   # prepare a version of the image that has its chroma shifted and less saturated
  28.   input_c = input.ChromaShift(C=Shift).tweak3(sat=stre)
  29.  
  30.   # combine both images using the mask
  31.   return input.overlay(input_c,mask=mask,mode="blend",opacity=1)
  32. }
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×