Log in

View Full Version : Restore Old VHS anime. How ?


FlaShow
15th November 2015, 13:18
Hello,

I have an old VHS Jap anime and has some artifact at the top as you can see in the images below.
Can you explain to me what is the problem exactly and how i can fix it ?

http://forum.doom9.org/attachment.php?attachmentid=15122&stc=1&d=1447589869

http://forum.doom9.org/attachment.php?attachmentid=15123&stc=1&d=1447589881

creaothceann
15th November 2015, 18:11
Looks like dotcrawl?

~ VEGETA ~
16th November 2015, 11:32
it looks like dotcrawl, but you may try denoising filters (spatial for example). They can be useful as I tried one in the deep past and worked well.

feisty2
16th November 2015, 11:44
I did see some kind of analog noise but I just don't think it's dot crawl...

feisty2
16th November 2015, 11:54
http://forum.doom9.org/showthread.php?t=172490
guess the problem is the same like this

JReiginsei
16th November 2015, 13:34
For the Chroma bands you may be able to make a mask so you can desaturate those areas.

raffriff42
16th November 2015, 15:29
## requires MaskTools2
## http://manao4.free.fr/mt_masktools.html

## kill color streaking at top of a VHS transfer
## http://forum.doom9.org/showthread.php?p=1647675#post1647675
ChromaDestripe(top=80, blur=6)

## Masked smoother for anime
## http://avisynth.nl/index.php/Msmooth
MSmooth(threshold=10, strength=2)

I'm using Msmooth for block smoothing, but it helps the RF noise (post #5) too.

EDIT those links again:
http://manao4.free.fr/mt_masktools.html
http://forum.doom9.org/showthread.php?p=1647675#post1647675
http://avisynth.nl/index.php/Msmooth

FlaShow
16th November 2015, 19:11
Thanks for the help :)

@raffriff42 I try to use your code but i can't get it to work even if i load Masktools2 ( )manually.
It says "There is no function named ChromaDestripe". I'm using MaskTools 2.0a48 ?

StainlessS
16th November 2015, 21:28
RaffRiff already gave you the link:- http://forum.doom9.org/showthread.php?p=1647675#post1647675

JReiginsei
17th November 2015, 03:10
raffriff42, do you have a YUY2 version of ChromaDestripe?

This ChromaDestripe function makes me want to re-do my VHS transfers since they all have the same problems with the stripes at the top.

raffriff42
17th November 2015, 05:26
OK this seems to work:#######################################
## try to 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)
##
## v0.42.02 16-Nov-2015 support YV24, YV16 and YUY2
##
function ChromaDestripe(clip C, int "top", int "blur", int "thresh")
{
Assert(C.IsYV12 || C.IsYV24 || C.IsYV16 || C.IsYUY2,
\ "ChromaDestripe: source must be YV12, YV24, YV16 or YUY2")

top = Max(0, Default(top, 160))
blur = Min(Max(2, Default(blur, 12)), 16)
thresh = Min(Max(0, Default(thresh, 6)), 32)
isYV12 = C.IsYV12

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

tw = V.Width
th = V.Height

## X = (highpass blurred anti-signal)

xh = Max(1, Round(th / (isYV12 ? 4 : 16)))
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 = (isYV12 ? top / 2 : top)
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)) / (isYV12 ? 1 : 2)
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)

YToUV(U, V, Y)
return (C.IsYUY2) ? ConvertToYUY2 : Last
}
The final Convert statement is needed because the output is otherwise YV16 (http://avisynth.nl/index.php/YV16), which (if I am not mistaken), can be losslessly converted (http://avisynth.nl/index.php/Convert) to YUY2 (and back). The chroma sampling is the same, it's just the arrangement in memory that's different (planar (http://avisynth.nl/index.php/Planar) YV16 vs. interleaved (http://avisynth.nl/index.php/Interleaved) YUY2)

FlaShow
17th November 2015, 18:03
@StainlessS sorry my bad :)

Thanks raffriff42. I have add this ChromaDestripe to plugin directory as avsi file but now it display
there is no function named "UtoY8" even after i used ConvertToYV12 after using AVISource ?

video info:
Color space : YUV
Chroma subsampling : 4:2:0
Bit depth : 8 bits

ChiDragon
17th November 2015, 18:33
there is no function named "UtoY8"
Y8 was added with Avisynth v2.60, so upgrade.

FlaShow
17th November 2015, 18:42
@ChiDragon Thanks :)

@raffriff42 Thanks for the code it is awesome :)