Log in

View Full Version : Old anime cleaning


_E_
30th April 2006, 06:57
Hi. I am having trouble filtering this horrendous anime. This is my script for now :

dedot()
TFM()
crop(6,0,704,480)
deflicker()
mq_filter()
Undot()
funkydeblock()
SmoothUV(3,64,false)

While it's cleaning most artifacts and keeping a reasonable amount of detail, it's causing macroblocks to appear in high motion/high blocky regions. Anyone got a suggestions for handling this video? Here's a sample vob :
http://rapidshare.de/files/19241525/sample.vob.html

AI
30th April 2006, 08:40
Му attempts (http://forum.doom9.org/showthread.php?p=817752#post817752)
and commentary about with prefilters (http://forum.doom9.org/showthread.php?p=819274#post819274)

Mug Funky
30th April 2006, 18:00
this source is actually pretty good, dude... hardly any grain, good telecine pattern... it lacks a lot of grain, so i think it's already been digitally restored (the He-Man stuff looks very similar to this, though they hit he-man a bit too hard, and lines/details disappear in more than a few places).

only thing it needs is a little black/white point adjustment ("levels(26,1,209)" is what i came up with quickly), and maybe a straight temporal smooth if you're compressing at a low bitrate to something sensitive to subtle luma changes.

you could also get away with "fastlinedarken" and probably limitedsharpen on this source as well - it's more blurry horizontally than vertically, as it's been put through a composite connection at some point.

dedot seems to help as well, but only on the edges of the screen.

BigDid
30th April 2006, 23:05
This is my script for now :
dedot()
TFM()
crop(6,0,704,480)
deflicker()
mq_filter()
Undot()
funkydeblock()
SmoothUV(3,64,false)
... it's causing macroblocks to appear in high motion/high blocky regions...
Hi,

Consider this as an attempt to approach anim filtering :o
I re-used AI params; more details in the thread linked by him :)
The tricky part is really the blockings appearing in a Q4 encode, not in a Q2 :devil:
---
dedot() # no change
TFM() # no change
crop(6,0,704,480) # no change; but I used autocrop in my script :)
deflicker() # no change
FrFun3b(4,3,6)
FrFun3b(2.8,1.8,4) # replaces mq_filter(); 2 occurences, 1st is preprocess, 2nd is with more stronger params than default (see AI post)
removegrain(mode=5) # replaces Undot(); should be mode=1 but I found mode=5 is better and near as conservative as mode=1
SmoothUV(2,64,true) # replaces SmoothUV(3,64,false); should be equivalent to false; but I don't see any rainbow effect in your clip :confused:
MSmooth(threshold=15,strength=3) #replaces funkydeblock(); This is quite strong and slow but the only way I found to reduce/smooth blocks and ringing for Q=4
---
Pictures taken (in png) from frame 212
1st is original
here: http://img241.imageshack.us/img241/6042/originalf2121fw.th.png (http://img241.imageshack.us/my.php?image=originalf2121fw.png)
2nd is Q2 encode filtered without MSmooth (no need)
here: http://img241.imageshack.us/img241/8109/xvid1passq2filteredf2129zp.th.png (http://img241.imageshack.us/my.php?image=xvid1passq2filteredf2129zp.png)
3rd is Q4 encode filtered with MSmooth
here: http://img260.imageshack.us/img260/4269/xvid1passq4filteredf2122zt.th.png (http://img260.imageshack.us/my.php?image=xvid1passq4filteredf2122zt.png)

Did

Edited, the last img was 1 frame ahead, re-uploaded

dbzgundam
30th April 2006, 23:18
Actually, the problem here is what I like to call "blocky grain". The original image has a fair amount of grain indeed, but the compression "warps" it... I see this in older cel-drawn anime all the time.

I find that using some smoothers (they really all have the problem of not being effective/blocking/banding, so it's your choice) on a supersampled level to be more effective. It'll at least minimize the effect if anything. Hqdn3d supersampled (or hell, Deen) seems to help. Try any smoother really.

Chainmax
1st May 2006, 03:15
Soulhunter once recommended me to use hqdn3d(0,0,3,3) as a temporal stabilizer and Mug Funky once said that DeGrainMedian() can remove some kinds of blocking. I think I saw some chroma noise in the first picture you posted, so I'd try something like:

FFT3DFilter(sigma=3,plane=3,bw=32,bh=32,bt=3,ow=16,oh=16,interlaced=true)
DeDot()
Crop(6,0,704,480,align=true)
IVTC
hqdn3d(0,0,3,3)
DeGrainMedian()
Lanczos4Resize(your_settings)
aWarpSharp(depth=16,cm=1)
LimitedSharpenFaster()

Also, why just TFM? is it a PAL source?


P.S + Edit: what is that image from?

BigDid
1st May 2006, 04:16
... P.S + Edit: what is that image from?
Hi,

If the question is from what Vob does that image come, it's from _E_ link, 1st post.
If the question is from what anim does it come from, dunno.

Having the link you could also try your settings?

Did

Chainmax
1st May 2006, 05:23
Can't do it right now, sorry. But he can try for himself since my script is simple (only LSF is a function, the rest can easily be found via search).

_E_
1st May 2006, 06:28
BigDid : Thanks, I am getting better results now using your script, though I found MSmooth at strenght 3 to be a bit too destructive -so I had to tone it down a bit. As for SmoothUV, yes there are rainbows in random areas of the vob, it just happens that the clip I uploaded didn't contain any. I also applied FLD , Levels and LimitedSharpen as MugFunky suggested. One thing left would be video shakiness and variable luma brightness , but I suppose little can be done to fix those.

AI
1st May 2006, 07:40
Now I am in searching for noise anime...
My last attempt:SetMemoryMax(272)
DGDecode_MPEG2Source("Robin.d2v")

FrFun3b(4,3,6)

bsz=16 lambd=2500*bsz*bsz/64 lamsad=800*bsz*bsz/64
backvect1=MVAnalyse(blksize=bsz, overlap=bsz/2, isb=false, truemotion=true, delta=1, idx=1, lambda=lambd, lsad=lamsad)
forwvect1=MVAnalyse(blksize=bsz, overlap=bsz/2, isb=true, truemotion=true, delta=1, idx=1, lambda=lambd, lsad=lamsad)
backvect2=MVAnalyse(blksize=bsz, overlap=bsz/2, isb=false, truemotion=true, delta=2, idx=1, lambda=lambd, lsad=lamsad)
forwvect2=MVAnalyse(blksize=bsz, overlap=bsz/2, isb=true, truemotion=true, delta=2, idx=1, lambda=lambd, lsad=lamsad)
backvect4=MVAnalyse(blksize=bsz, overlap=bsz/2, isb=false, truemotion=true, delta=4, idx=1, lambda=lambd, lsad=lamsad)
forwvect4=MVAnalyse(blksize=bsz, overlap=bsz/2, isb=true, truemotion=true, delta=4, idx=1, lambda=lambd, lsad=lamsad)

SCD1=800 SCD2=80
ScenChange1=YtoUV(MVSCDetection(vectors=backvect1, thSCD1=SCD1, thSCD2=SCD2).Crop(0,0,32,4),\
MVSCDetection(vectors=forwvect1, thSCD1=SCD1, thSCD2=SCD2).Crop(0,0,32,4))
ScenChange2=YtoUV(ConditionalFilter(ScenChange1, ScenChange1.UtoY, MVSCDetection(vectors=backvect2, thSCD1=SCD1, thSCD2=SCD2).Crop(0,0,32,4),"AverageChromaU","=","255"),\
ConditionalFilter(ScenChange1, ScenChange1.VtoY, MVSCDetection(vectors=forwvect2, thSCD1=SCD1, thSCD2=SCD2).Crop(0,0,32,4),"AverageChromaV","=","255"))
ScenChange4=YtoUV(ConditionalFilter(ScenChange2, ScenChange2.UtoY, MVSCDetection(vectors=backvect4, thSCD1=SCD1, thSCD2=SCD2).Crop(0,0,32,4),"AverageChromaU","=","255"),\
ConditionalFilter(ScenChange2, ScenChange2.VtoY, MVSCDetection(vectors=forwvect4, thSCD1=SCD1, thSCD2=SCD2).Crop(0,0,32,4),"AverageChromaV","=","255"))
ScenChange1=MergeChroma(Logic(ScenChange1.UtoY,ScenChange1.VtoY),ScenChange1.Crop(0,0,32,4))
ScenChange2=MergeChroma(Logic(ScenChange2.UtoY,ScenChange2.VtoY),ScenChange1.Crop(0,0,32,4))
ScenChange4=MergeChroma(Logic(ScenChange4.UtoY,ScenChange4.VtoY),ScenChange1.Crop(0,0,32,4))

backComp1= Last.MVFlow(backvect1, thSCD1=SCD1, thSCD2=SCD2, idx=1)
forwComp1= Last.MVFlow(forwvect1, thSCD1=SCD1, thSCD2=SCD2, idx=1)
backComp2= Last.MVFlow(backvect2, thSCD1=SCD1, thSCD2=SCD2, idx=1)
forwComp2= Last.MVFlow(forwvect2, thSCD1=SCD1, thSCD2=SCD2, idx=1)
backComp3= backComp1.MVFlow(backvect2, thSCD1=SCD1, thSCD2=SCD2)
forwComp3= forwComp1.MVFlow(forwvect2, thSCD1=SCD1, thSCD2=SCD2)

backComp4= Last.MVFlow(backvect4, thSCD1=SCD1, thSCD2=SCD2, idx=1)
forwComp4= Last.MVFlow(forwvect4, thSCD1=SCD1, thSCD2=SCD2, idx=1)
backComp5= backComp1.MVFlow(backvect4, thSCD1=SCD1, thSCD2=SCD2)
forwComp5= forwComp1.MVFlow(forwvect4, thSCD1=SCD1, thSCD2=SCD2)
backComp6= backComp2.MVFlow(backvect4, thSCD1=SCD1, thSCD2=SCD2)
forwComp6= forwComp2.MVFlow(forwvect4, thSCD1=SCD1, thSCD2=SCD2)
backComp7= backComp3.MVFlow(backvect4, thSCD1=SCD1, thSCD2=SCD2)
forwComp7= forwComp3.MVFlow(forwvect4, thSCD1=SCD1, thSCD2=SCD2)

backCom7a=ScriptClip(backComp7, "AverageChromaU(ScenChange2) == 255 || \
AverageChromaU(ScenChange4.FadeIn2(0)) == 255 || \
LumaDifference(Last,backComp6) < 1 ? forwComp1 : Last")
forwCom7a=ScriptClip(forwComp7, "AverageChromaV(ScenChange2) == 255 || \
AverageChromaV(ScenChange4.Trim(2,0)) == 255 || \
LumaDifference(Last,forwComp6) < 1 ? backComp1 : Last")

backCom6a=ScriptClip(forwComp2, "AverageChromaU(ScenChange2) == 255 || \
AverageChromaU(ScenChange4.FadeIn2(0)) == 255 ? Last : backComp6")
forwCom6a=ScriptClip(backComp2, "AverageChromaV(ScenChange2) == 255 || \
AverageChromaV(ScenChange4.Trim(2,0)) == 255 ? Last : forwComp6")

backCom5a=ScriptClip(forwComp3, "AverageChromaU(ScenChange1) == 255 || \
AverageChromaU(ScenChange4.FadeIn(0)) == 255 ? Last : backComp5")
forwCom5a=ScriptClip(backComp3, "AverageChromaV(ScenChange1) == 255 || \
AverageChromaV(ScenChange4.Trim(1,0)) == 255 ? Last : forwComp5")

backCom4a=ConditionalFilter(ScenChange4,forwComp4,backComp4,"AverageChromaU","=","255")
forwCom4a=ConditionalFilter(ScenChange4,backComp4,forwComp4,"AverageChromaV","=","255")

backCom3a=ScriptClip(ConditionalFilter(ScenChange4,forwComp1,forwComp5,"AverageLuma","=","255"),\
"AverageChromaU(ScenChange1) == 255 || \
AverageChromaU(ScenChange2.FadeIn(0)) == 255 ? Last : backComp3")
forwCom3a=ScriptClip(ConditionalFilter(ScenChange4,backComp1,backComp5,"AverageLuma","=","255"),\
"AverageChromaV(ScenChange1) == 255 || \
AverageChromaV(ScenChange2.Trim(1,0)) == 255 ? Last : forwComp3")

backCom2a=ScriptClip(backComp2, "AverageChromaU (ScenChange2) != 255 ? Last : \
AverageLuma (ScenChange4) != 255 ? forwComp6 : forwComp2")
forwCom2a=ScriptClip(forwComp2, "AverageChromaV (ScenChange2) != 255 ? Last : \
AverageLuma (ScenChange4) != 255 ? backComp6 : backComp2")

backCom1a=ScriptClip(backComp1, "AverageChromaU (ScenChange1) != 255 ? Last : \
AverageLuma (ScenChange4) != 255 ? forwComp7 : \
AverageLuma (ScenChange2) != 255 ? forwComp3 : forwComp1")
forwCom1a=ScriptClip(forwComp1, "AverageChromaV (ScenChange1) != 255 ? Last : \
AverageLuma (ScenChange4) != 255 ? backComp7 : \
AverageLuma (ScenChange2) != 255 ? backComp3 : backComp1")

Interleave( backCom7a, backCom6a, backCom5a,\
backCom4a, backCom3a, backCom2a, backCom1a,\
Last,\
forwCom1a, forwCom2a, forwCom3a, forwCom4a,\
forwCom5a, forwCom6a, forwCom7a)

TTemp7=TTempSmooth(7,24,16,12,8,7,30,true,\
pfclip=Interleave( backCom7a, backCom6a, backCom5a,\
backCom4a, backCom3a, backCom2a, backCom1a,\
TemporalSoften(7,32,24,mode=2).SelectEvery(15,7).UnDot,\
forwCom1a, forwCom2a, forwCom3a, forwCom4a,\
forwCom5a, forwCom6a, forwCom7a)).\
SelectEvery(15,7)

TTemp3=TTempSmooth(3,16,12,8,6,3,20,true,\
pfclip=Interleave( backCom7a, backCom6a, backCom5a,\
backCom4a, backCom3a, backCom2a, backCom1a,\
TemporalSoften(3,24,16,mode=2).SelectEvery(15,7).UnDot,\
forwCom1a, forwCom2a, forwCom3a, forwCom4a,\
forwCom5a, forwCom6a, forwCom7a)).\
SelectEvery(15,7)

TTemp1=TTempSmooth(1,12,8,6,4,1,10,true,\
pfclip=Interleave( backCom7a, backCom6a, backCom5a,\
backCom4a, backCom3a, backCom2a, backCom1a,\
TemporalSoften(1,16,12,mode=2).SelectEvery(15,7).UnDot,\
forwCom1a, forwCom2a, forwCom3a, forwCom4a,\
forwCom5a, forwCom6a, forwCom7a)).\
SelectEvery(15,7)

ScriptClip(SelectEvery(15,7), "AverageLuma(ScenChange4) != 255 ? TTemp7 : \
AverageLuma(ScenChange2) != 255 ? TTemp3 : \
AverageLuma(ScenChange1) != 255 ? TTemp1 : Last")

Optim=Last

backCom1b=MVFlow(vectors=backvect1, thSCD1=SCD1, thSCD2=SCD2)
forwCom1b=MVFlow(vectors=forwvect1, thSCD1=SCD1, thSCD2=SCD2)
backCom2b=MVFlow(vectors=backvect2, thSCD1=SCD1, thSCD2=SCD2)
forwCom2b=MVFlow(vectors=forwvect2, thSCD1=SCD1, thSCD2=SCD2)
backCom4b=MVFlow(vectors=backvect4, thSCD1=SCD1, thSCD2=SCD2)
forwCom4b=MVFlow(vectors=forwvect4, thSCD1=SCD1, thSCD2=SCD2)

backCom4c=ConditionalFilter(ScenChange4,forwCom1b,backCom4b,"AverageChromaU","=","255")
forwCom4c=ConditionalFilter(ScenChange4,backCom1b,forwCom4b,"AverageChromaV","=","255")

backCom2c=ScriptClip(backCom2b, "AverageChromaU (ScenChange2) != 255 ? Last : \
AverageLuma (ScenChange4) != 255 ? forwCom4b : forwCom1b")
forwCom2c=ScriptClip(forwCom2b, "AverageChromaV (ScenChange2) != 255 ? Last : \
AverageLuma (ScenChange4) != 255 ? backCom4b : backCom1b")

backCom1c=ScriptClip(backCom1b, "AverageChromaU (ScenChange1) != 255 ? Last : \
AverageLuma (ScenChange2) != 255 ? forwCom2b : forwCom1b")
forwCom1c=ScriptClip(forwCom1b, "AverageChromaV (ScenChange1) != 255 ? Last : \
AverageLuma (ScenChange2) != 255 ? backCom2b : backCom1b")

ConditionalFilter(ScenChange4,Last,Interleave(backCom4c,Last,forwCom4c).\
DeGrainMedian(16,24,3).\
SelectEvery(3,1),"AverageLuma","=","255")

ConditionalFilter(ScenChange2,Last,Interleave(backCom2c,Last,forwCom2c).\
DeGrainMedian(8,12,2).\
SelectEvery(3,1),"AverageLuma","=","255")

ConditionalFilter(ScenChange1,Last,Interleave(backCom1c,Last,forwCom1c).\
DeGrainMedian(4,6,1).\
SelectEvery(3,1),"AverageLuma","=","255")

FrFun3b(3,2,4)

MergeLuma(TurnLeft. FFT3DGPU(sigma=3, bt=4, mode=2, plane=1).TurnRight,\
MergeChroma(Optim.Trim(5,0)).FFT3DGPU(sigma=1, bh=16, bw=16, bt=4, mode=2, plane=0, precision=1))

Dup(5,maxcopies=1,blend=true)Edit:Optimized use internal cach - Now Need 512Mb RAM
PS I use preCroping in d2v:Clipping=12,12,4,4

Chainmax
1st May 2006, 16:34
Adding motion stabilization:

MPEG2Source(whatever)
i = last
mdata = DePanEstimate(i)
DePanStabilize(i, data=mdata,addzoom=true,prev=1)
FFT3DFilter(sigma=3,plane=3,bw=32,bh=32,bt=3,ow=16,oh=16,interlaced=true)
DeDot()
Crop(6,0,704,480,align=true)
IVTC
hqdn3d(0,0,3,3)
DeGrainMedian()
Lanczos4Resize(your_settings)
aWarpSharp(depth=16,cm=1)
LimitedSharpenFaster()


Unanswered questions: 1) what anime is that image from?

2) why only TFM? is it a PAL source?

BigDid
2nd May 2006, 19:57
@ _E_

I would appreciate (and maybe other readers too) to have your resulting finalized and optimized script: remember I am a noob for anim filtering, and if you could upload a pic (same frame) that would be great; imageshack is really easy :)

Thanks in advance.

Did

SirCanealot
3rd May 2006, 21:22
BigDad, his script will be optimised to work only with this series; it won't be effective on another show. While he could post, it shouldn't be used on other shows :/

AI
4th May 2006, 13:19
I Edit my script for cleaning very noise anime:
- Optimized use internal cach - Now Need 512Mb RAM
- possible optimized quality
- possible optimized speed

I want write script with "Motion" and maxRadius=3 for faster
Anyone need it? (or I lose time?)