Log in

View Full Version : Attempt to stabilize fluctuation(flickering?) in old anime


lansing
8th June 2009, 23:33
This question arose occasionally here and I didn't really see any proper solution to it. Stabilizing filters like depan or mvdepan was not enough, in which the inner part of the frame still fluctuate like crazy on playback. Here's my attempt to clean it up

LRemoveDust(2,10) #stabilize inner frame fluctuation
stab() #global stablize
fastdegrain() #reduce flickering along lines


The problem I have with this is that LRemoveDust has to set to (2,>10) in order to be effective, but at the same time it blurs everything that pans:mad:

I've uploaded 2 samples (http://www.mediafire.com/download.php?djgw2wkyb3h) to test with, the first one is a stilled scene, where and script works well, and the second sample is the one I have problem with panning.

Is there any way to modify LRemoveDust to the leave panning areas along?


UPDATE:

Link (http://forum.doom9.org/showthread.php?p=1569657#post1569657) to updated script

thetoof
9th June 2009, 02:41
Something I liked to do with old anime was stab with a high dy/xmax + msmooth for "edge noise" or ringing + (for hard cases) temporaldegrain with a fft3d prefiltered clip + dithering (overkill, maybe, but for crappy sources.....)

For line flickering, by LaTo :
strength = 3

mt_merge(last,last.MVDegrainMulti(last.FFT3Dgpu(sigma=strength*2,plane=4,bw=32,bh=32,ow=8,oh=8,bt=3).MVanalyseMulti(refframes=strength,blksize=16,overlap=4,idx=1),refframes=strength,thSAD=strength*200,idx=1),last.mt_edge("min/max").removegrain(19),U=3,V=3)

lansing
9th June 2009, 04:46
Something I liked to do with old anime was stab with a high dy/xmax + msmooth for "edge noise" or ringing + (for hard cases) temporaldegrain with a fft3d prefiltered clip + dithering (overkill, maybe, but for crappy sources.....)

For line flickering, by LaTo :
strength = 3

mt_merge(last,last.MVDegrainMulti(last.FFT3Dgpu(sigma=strength*2,plane=4,bw=32,bh=32,ow=8,oh=8,bt=3).MVanalyseMulti(refframes=strength,blksize=16,overlap=4,idx=1),refframes=strength,thSAD=strength*200,idx=1),last.mt_edge("min/max").removegrain(19),U=3,V=3)

nice tips, something like this could be suitable for most scene on old anime:

stab(1,10,10)

temporaldegrain(gpu=true)
################################
strength = 3

mt_merge(last,
\ last.MVDegrainMulti(last.FFT3Dgpu(sigma=strength*2,plane=4,bw=32,bh=32,ow=8,oh=8,bt=3).MVanalyseMulti(refframes=strength,blksize=16,overlap=4,idx=1),refframes=strength,thSAD=strength*200,idx=1),
\ last.mt_edge("min/max").removegrain(19),
\ U=3,V=3)
#################################
#some cropping and resizing


The only problem I have with this is that it also darkens(blur?) small bright spots such as a panning shot of a sky that's full of stars. See this sample here (http://www.mediafire.com/download.php?nyjdomxl1yg).

thetoof
9th June 2009, 05:16
a user-defined prefiltered clip for temporaldegrain will help avoiding too agressive denoising. I personally like tweaking sigmas with fft3dfilter.

lansing
9th June 2009, 06:08
a user-defined prefiltered clip for temporaldegrain will help avoiding too agressive denoising. I personally like tweaking sigmas with fft3dfilter.

the problem lies on the flicker reducing part, because even though I removed TemporalDegrain, the house lights in sample3 still seems blurry on panning.

onesloth
9th June 2009, 11:46
After using stab() on sample1 it looks like the frames are stretching and squishing vertically. And in some frames only parts of the frame appear to stretch from one frame to the next. That might be why stab() can't really stabilize the picture. I tried using zoom estimation to compensate for this but no luck.

I wonder if an incorrect deinterlace or IVTC could be at fault here? Like somehow the wrong fields in different parts of the frame were weaved.

thetoof
9th June 2009, 13:03
the problem lies on the flicker reducing part, because even though I removed TemporalDegrain, the house lights in sample3 still seems blurry on panning. Quite possible... could be fixed with a lut. The line comes from an old script on MSG 0079.

a=td
b=a.deflicker
mt_lutxy(a,b,string(mt_polish("y>235 ? .5*y + .5*x : y")),chroma="copy second")

Change the numbers according to your preferences. For now it means "when luma from the deflickered clip is higher than 235, use the average of the denoised and deflickered clip for the output clip. If it's lower, do nothing. Take chroma from the deflickered clip to prevent flickering chroma".

Other options are out there... one being ajusting the strength of the deflickering script.

lansing
9th June 2009, 22:08
@onesloth

Yes, stab() or any other stabilizing filter alone will not work on this, nor does any temporal smoother. And I think this flickering problem doesn't have anything to do with IVTC, since most old anime in the 90s were like that.

@toof

I change the strength to 1 in that deflickering script, and it works fine in all three samples now, yay. One minor problem is the small flickering on the top and bottom of the frame sometime, but I can live with that. I'll put the script here just for future references:

stab(1,10,10)
temporaldegrain(gpu=true)
########################################################
strength = 1

mt_merge(last,
\ last.MVDegrainMulti(last.FFT3Dgpu(sigma=strength*2,plane=4,bw=32,bh=32,ow=8,oh=8,bt=3).MVanalyseMulti(refframes=strength,blksize=16,overlap=4,idx=1),refframes=strength,thSAD=strength*200,idx=1),
\ last.mt_edge("min/max").removegrain(19),
\ U=3,V=3)
#########################################################

#some cropping and resizing

Terka
10th June 2009, 08:52
try TGMC routines.

lansing
12th April 2012, 16:20
to dig this thread back up, as I learn more about how the mt_merge and mt_edge work, i can concluded, in my many tests the last two days, the key of the whole thing is the sigma value of the fft3dgpu/fft3dfilter, setting it to 4 or 5 will basically get the job done. And the temporaldegrain script is not necessary. So the updated script will be:


o=AVISource("D:\video samples\sample1.avi").stab() #global stabilize the video

###############################

_fft = 5
_thSAD = 100
_bs = 16
_ov = 4

FFT3Dgpu(o,sigma=_fft)

super = last.MSuper()
b3v = MAnalyse(super, isb=true, delta=3, blksize=_bs, overlap=_ov)
b2v = MAnalyse(super, isb=true, delta=2, blksize=_bs, overlap=_ov)
b1v = MAnalyse(super, isb=true, delta=1, blksize=_bs, overlap=_ov)
f1v = MAnalyse(super, delta=1, blksize=_bs, overlap=_ov)
f2v = MAnalyse(super, delta=2, blksize=_bs, overlap=_ov)
f3v = MAnalyse(super, delta=3, blksize=_bs, overlap=_ov)

process = MDeGrain1(super, b1v, f1v, thSAD=_thSAD)
#process = MDeGrain2(osuper, b1v, f1v, b2v, f2v, thSAD=_thSAD)
#process = MDeGrain3(super, b1v, f1v, b2v, f2v, b3v, f3v, thSAD=_thSAD)

mt_merge(o, process, o.mt_edge("min/max").RemoveGrain(19), U=3, V=3)

###############################

#some cropping and resizing


the above mdegrain script comes from here (http://forum.doom9.org/showthread.php?p=1396262#post1396262), as that thread also deals with this same problem, and that script is the conversion of the MVDegrainMulti which came from this thread. Okay, enough of the confusion.

The detail processes of script are, first global stabilize the video clip1; then create clip2 of dead calm pixels using fft3dgpu+mdegrain (fft3dgpu alone could be enough, but in my sample1, the lines are still not calm enough yet); and then create an edge mask of clip1; and finally merge only the edge of clip1 with the dead calm edge(lines) of clip2.

The Removegrain(19) after mt_edge was there to remove any dirt in the mask that were mistaken as edge.

note: Msuper only seems to work with "last", I got error "Mdegrain1: wrong source size" if I wrote like this: "prefilter.MSuper()".

________________________________________________

Here are the other alternatives I've tried but didn't satisfy my taste:


QTGMC(Preset="Slower", InputType=1, TR2=3)

straight from QTGMC's documentation, no stab() is needed for this one, does eliminated the line flickers, but also introduced ghosting on my sample.




o=AVISource("D:\video samples\sample3.avi").stab()

tblur = o.TemporalCleaner (ythresh=25, cthresh=10).fft3dgpu(sigma=3)

mt_merge(o, tblur, o.mt_edge("min/max").removegrain(19), U=3,V=3)

uses TemporalCleaner+fft3dgpu instead of fft3dgpu+mdegrain.
ythresh above 30 will causes ghosting, fft3dgpu was throw in to smooth out jaggy lines that may be introduced by temporalcleaner. This one also eliminate the line flickers, but it manipulated the image too much for my taste, such as lines started to thin out in motion scene.