View Single Post
Old 13th October 2013, 14:30   #6  |  Link
raffriff42
Retried Guesser
 
raffriff42's Avatar
 
Join Date: Jun 2012
Posts: 1,373
I dunno, looks like skew (tape tension) error maybe. Here's an experimental script that might help.
Code:
## requires MaskTools2
LoadPlugin(pathBase + "MaskTools2\mt_masktools-26.dll")

## <<YV12 source>>

ChromaDestripe()
#return Last

## optional color correction
ConvertToRGB()
return MergeRGB(
\    ShowRed.Levels(0, 1.10, 255, 0, 255), 
\    ShowGreen.Levels(0, 1.0, 255, 0, 255), 
\    ShowBlue.Levels(0, 0.75, 200, 0, 255)
\  ).Levels(15, 1.2, 235, 0, 255) 

#######################################
## remove horizontal chroma stripes
##
## @ top - number of pixels (from top) to process (default 160)
## @ blur - vertical chroma blur radius (default 12)
## @ thresh - ignore smaller chroma changes (default 6)
##
function ChromaDestripe(clip C, int "top", int "blur", int "thresh")
{
    top    = Max(0, Default(top, 160))
    blur   = Min(Max(2, Default(blur,  12)), 16)
    thresh = Min(Max(0, Default(thresh, 6)), 32)

    U = C.UToY8
    V = C.VToY8
    Y = C.ConvertToY8
#return Y

    tw = V.Width
    th = V.Height

    ## X = (highpass blurred anti-signal)

    xh = Max(1, Round(th / 4))
    XU=U.BilinearResize(tw, xh, src_top=1, src_height=(th-2))
    \   .BilinearResize(tw, th) 
    XV=V.BilinearResize(tw, xh, src_top=1, src_height=(th-2))
    \   .BilinearResize(tw, th)
#return XU

    ## H = highpass - find bold horizontal U & V edges

    HU=U.Subtract(XU).Invert.ColorYUV(cont_y=98)
    HV=V.Subtract(XV).Invert.ColorYUV(cont_y=98)
#return HU.Histogram

    ## M = mask - pass only areas with bold hor. U & V edges

    MU=HU.mt_lut("x 128 - abs " + String(thresh) + " - 512 * ")
    MV=HV.mt_lut("x 128 - abs " + String(thresh) + " - 512 * ")
#return MU

    MU=MU.mt_expand
    \    .BilinearResize(tw/4, th/4)
    \    .mt_expand.mt_expand
    \    .BilinearResize(tw, th) 
    MV=MV.mt_expand 
    \    .BilinearResize(tw/4, th/4)
    \    .mt_expand.mt_expand
    \    .BilinearResize(tw, th) 
#return MU

    ## restrict mask to "top" pixels

    top = top / 2
    MU = (top<=0 || top>=th) 
    \       ? MU 
    \       : MU.Crop(0, 0, -0, top).AddBorders(0, 0, 0, (th-top))  
    MV = (top<=0 || top>=th) 
    \       ? MV 
    \       : MV.Crop(0, 0, -0, top).AddBorders(0, 0, 0, (th-top))
#return MU

    ## B = chroma blur

    nh = Max(1, Round(th / blur))
    BU=U.BilinearResize(tw, nh, src_top=1, src_height=(th-2))
    \   .BilinearResize(tw, th) 
    BV=V.BilinearResize(tw, nh, src_top=1, src_height=(th-2))
    \   .BilinearResize(tw, th)
#return BU

    ## use blurred chroma in areas of high variation

    U=U.Overlay(BU, mode="blend", opacity=1.0, mask=MU)
#return U
    V=V.Overlay(BV, mode="blend", opacity=1.0, mask=MV)

    return YToUV(U, V, Y)
}
I don't have any video around with this type of error, but the script helps the sample image and doesn't seem to hurt normal footage. With one exception: color bars get smeared.

Here's the progress of the U channel (most of the error in this example is in the U channel, but both channels are processed in the script)

Last edited by raffriff42; 18th March 2017 at 01:21. Reason: (fixed image links)
raffriff42 is offline   Reply With Quote