View difference between Paste ID: y3JfEFdf and Y0RQYJNr
SHOW: | | - or go back to the newest paste.
1-
# FixChromaBleedingMod v1.2
1+
# FixChromaBleedingMod v1.3
2
3-
Function FixChromaBleedingMod (clip input, int "Shift", float "thr", float "strength", bool "f", float "opacity") {
3+
Function FixChromaBleedingMod (clip input, int "cxShift", int "cyShift", float "thr", float "strength", bool "f", float "opacity", bool "n", bool "xysh", bool "Bic") {
4
5-
  Shift	= default ( Shift,       -4 )
5+
  xShift = default ( cxShift,       -4 )
6-
  thr	= default ( thr,       4.0 )
6+
  yShift = default ( cyShift,       -4 )
7-
  stre = default ( strength,       0.8 )
7+
  thr	 = default ( thr,         4.0 )
8
  stre = default ( strength,      0.8 )
9
  f =  default ( f,       true )
10
  n =  default ( n,       false )
11
  sh =  default ( xysh,       false )
12
  Bic = default ( Bic,       false )
13-
  area = input.tweak(sat=thr).VtoY.Blur(1)
13+
14
15
  # prepare to work on the V channel and reduce to speed up and filter noise
16
  areaf = input.tweak(sat=thr).VtoY.ReduceBy2
17
  area = n ? input.tweak(sat=thr).VtoY.Blur(1) : input.tweak(sat=thr).VtoY
18
19
  # select and normalize both extremes of the scale
20-
  maskc = MergeLuma(red, blue, 0.5).Levels(250,1.0,250,255,0)
20+
21
  blue = f ? areaf.Levels(0,1.0,0,0,255) : area.Levels(0,1.0,0,0,255)
22
23-
   maskc = maskc.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)
23+
24
  maskc = n ? MergeLuma(red, blue, 0.5).Levels(250,1.0,250,255,0) : f ?  MergeLuma(red, blue, 0.5).Levels(250,1.0,250,255,0) : MergeLuma(red, blue, 0.5).Blur(1).Levels(250,1.0,250,255,0) 
25
26-
  maskc = maskc.BilinearResize(Width(input),Height(input)).Levels(10,1.0,10,0,255)
26+
27
   maskc = IsPlanar(input) ? maskc.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) : maskc.ConvertToRGB32.GeneralConvolution(0,"0 0 0 0 0 1 1 1 0 0 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0").ConvertToYV12
28
29-
  input_c = input.ChromaShift(C=Shift).tweak(sat=stre)
29+
30
  maskc = Bic ? maskc.BicubicResize(Width(input),Height(input)).Levels(10,1.0,10,0,255) : maskc.BilinearResize(Width(input),Height(input)).Levels(10,1.0,10,0,255)
31
32
  # prepare a version of the image that has its chroma shifted and less saturated
33
  input_c = sh ? input.ChromaShiftSP(x=xShift,y=yShift).tweak(sat=stre) : input.ChromaShift(C=xShift).tweak(sat=stre)
34
35
  # combine both images using the mask
36
  return input.overlay(input_c,mask=maskc,mode="blend",opacity=opacity)
37
}