Welcome to Doom9's Forum, THE in-place to be for everyone interested in DVD conversion.

Before you start posting please read the forum rules. By posting to this forum you agree to abide by the rules.

 

Go Back   Doom9's Forum > Capturing and Editing Video > Avisynth Usage

Reply
 
Thread Tools Search this Thread Display Modes
Old 8th June 2009, 23:33   #1  |  Link
lansing
Registered User
 
Join Date: Sep 2006
Posts: 796
Attempt to stabilize fluctuation(flickering?) in old anime

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

Code:
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

I've uploaded 2 samples 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 to updated script

Last edited by lansing; 12th April 2012 at 16:25. Reason: updated link
lansing is online now   Reply With Quote
Old 9th June 2009, 02:41   #2  |  Link
thetoof
Sleepy overworked fellow
 
Join Date: Feb 2008
Location: Maple syrup's homeland
Posts: 933
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 :
Code:
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)
__________________
AnimeIVTC() - v2.00
-http://boinc.berkeley.edu/-
Let all geeks use their incredibly powerful comps for the greater good (no, no, it won't slow your filtering/encoding :p)
thetoof is offline   Reply With Quote
Old 9th June 2009, 04:46   #3  |  Link
lansing
Registered User
 
Join Date: Sep 2006
Posts: 796
Quote:
Originally Posted by thetoof View Post
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 :
Code:
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:

Code:
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.
lansing is online now   Reply With Quote
Old 9th June 2009, 05:16   #4  |  Link
thetoof
Sleepy overworked fellow
 
Join Date: Feb 2008
Location: Maple syrup's homeland
Posts: 933
a user-defined prefiltered clip for temporaldegrain will help avoiding too agressive denoising. I personally like tweaking sigmas with fft3dfilter.
__________________
AnimeIVTC() - v2.00
-http://boinc.berkeley.edu/-
Let all geeks use their incredibly powerful comps for the greater good (no, no, it won't slow your filtering/encoding :p)
thetoof is offline   Reply With Quote
Old 9th June 2009, 06:08   #5  |  Link
lansing
Registered User
 
Join Date: Sep 2006
Posts: 796
Quote:
Originally Posted by thetoof View Post
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.
lansing is online now   Reply With Quote
Old 9th June 2009, 11:46   #6  |  Link
onesloth
Registered User
 
Join Date: Jul 2007
Posts: 137
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.

Last edited by onesloth; 9th June 2009 at 14:45.
onesloth is offline   Reply With Quote
Old 9th June 2009, 13:03   #7  |  Link
thetoof
Sleepy overworked fellow
 
Join Date: Feb 2008
Location: Maple syrup's homeland
Posts: 933
Quote:
Originally Posted by lansing View Post
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.

Code:
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.
__________________
AnimeIVTC() - v2.00
-http://boinc.berkeley.edu/-
Let all geeks use their incredibly powerful comps for the greater good (no, no, it won't slow your filtering/encoding :p)
thetoof is offline   Reply With Quote
Old 9th June 2009, 22:08   #8  |  Link
lansing
Registered User
 
Join Date: Sep 2006
Posts: 796
@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:

Code:
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
lansing is online now   Reply With Quote
Old 10th June 2009, 08:52   #9  |  Link
Terka
Registered User
 
Join Date: Jan 2005
Location: cz
Posts: 676
try TGMC routines.
Terka is offline   Reply With Quote
Old 12th April 2012, 16:20   #10  |  Link
lansing
Registered User
 
Join Date: Sep 2006
Posts: 796
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:

Code:
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, 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:


Code:
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.




Code:
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.

Last edited by lansing; 12th April 2012 at 19:24. Reason: typo
lansing is online now   Reply With Quote
Reply

Tags
anime, flicker, stabilize

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 10:16.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2017, vBulletin Solutions Inc.