SHOW:
|
|
- or go back to the newest paste.
1 | - | Function FixChromaBleedingMod (clip input, int "Shift") { |
1 | + | # FixChromaBleedingMod v1.1 |
2 | ||
3 | - | # Shift = default ( Shift, -4 ) |
3 | + | Function FixChromaBleedingMod (clip input, int "Shift", float "thr", float "strength", bool "f") { |
4 | ||
5 | Shift = default ( Shift, -4 ) | |
6 | - | area = input.tweak3(sat=4.0).VtoY.ReduceBy2 |
6 | + | thr = default ( thr, 4.0 ) |
7 | stre = default ( strength, 0.8 ) | |
8 | f = default ( f, true ) | |
9 | - | red = area.Levels(255,1.0,255,255,0) |
9 | + | |
10 | - | blue = area.Levels(0,1.0,0,0,255) |
10 | + | |
11 | areaf = input.tweak3(sat=thr).VtoY.ReduceBy2 | |
12 | area = input.tweak3(sat=thr).VtoY.Blur(1.5) | |
13 | - | mask = MergeLuma(red, blue, 0.5).Levels(250,1.0,250,255,0) |
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 | - | 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) |
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 = mask.BilinearResize(Width(input),Height(input)).Levels(10,1.0,10,0,255) |
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 | - | input_c = input.ChromaShift(C=Shift).tweak3(sat=0.8) |
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 | - | return input.overlay(input_c,mask=mask,mode="blend",opacity=0.7) |
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 | } |