Advertisement
Guest User

FixChromaBleedingMod

a guest
Jan 31st, 2014
228
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Function FixChromaBleedingMod (clip input, int "Shift") {
  2.  
  3. # Shift = default ( Shift,       -4 )
  4.  
  5.   # prepare to work on the V channel and reduce to speed up and filter noise
  6.   area = input.tweak3(sat=4.0).VtoY.ReduceBy2
  7.  
  8.   # select and normalize both extremes of the scale
  9.   red = area.Levels(255,1.0,255,255,0)
  10.   blue = area.Levels(0,1.0,0,0,255)
  11.  
  12.   # merge both masks
  13.   mask = MergeLuma(red, blue, 0.5).Levels(250,1.0,250,255,0)
  14.  
  15.   # expand to cover beyond the bleeding areas and shift to compensate the resizing
  16.    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)
  17.  
  18.   # back to full size and binarize (also a trick to expand)
  19.   mask = mask.BilinearResize(Width(input),Height(input)).Levels(10,1.0,10,0,255)
  20.  
  21.   # prepare a version of the image that has its chroma shifted and less saturated
  22.   input_c = input.ChromaShift(C=Shift).tweak3(sat=0.8)
  23.  
  24.   # combine both images using the mask
  25.   return input.overlay(input_c,mask=mask,mode="blend",opacity=0.7)
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement