View Full Version : MaskDeinterlacer
joshbm
10th September 2004, 05:22
MaskDeint: Script updated 9/23/04, input needed :D!
1.) KernelDeint
2.) TDeint [edit]
3.) SangNom [edit]
4.) SmoothDeinterlace
5.) TomsMoComp (smoothing)
[edit] Tested with NTSC DV material from a Sony VX2000 Camera.
I started creating this function when I was deinterlacing a video using KernelDeint and I was noticing mice teeth. This bothering me, I decided to create a function to get the best of all the worlds. I've used all the deinterlacers above in past projects and decided I would create a Deinterlacer that combined all of them together. Overall, I think it creates an excellent image-- no mice teeth, interlacing artifacts etc.
function MaskDeint(clip a,bool "bob",int "order",bool "soften")
{
soften=default(soften,true)
bob=default(bob,false)
findOrder=default(order,getparity(a) ? 1 : 0)
a=a.ConvertToYV12()
v1=(bob==false) ? a.KernelDeint(order=findOrder,sharp=false,twoway=false) :
\ a.KernelBob(order=findOrder,sharp=false,twoway=false)
v2=(bob==false) ? a.TDeint(order=findOrder,mode=0,type=2) :
\ a.TDeint(order=findOrder,mode=1,type=2)
v3=(bob==false) ? a.SangNom(findOrder,aa=32) :
\ Interleave(a.SangNom(findOrder,aa=32),a.SangNom(Abs(findOrder-1),aa=32))
v4=(bob==false) ? a.ConvertToYUY2().SmoothDeinterlace().ConvertToYV12() :
\ a.ConvertToYUY2().SmoothDeinterlace(doublerate=true).ConvertToYV12()
over1=merge(v1,v3)
over2=merge(v2,v4)
over3=merge(over1,over2)
return (soften==true) ? over3.AssumeFps(over3.framerate)
\ .TomsMoComp(1,-1,1).Lanczos4Resize(a.width,a.height) : over3
}
function merge(clip a,clip b,float "opacity"){
opacity=default(opacity,0.5)
return a.MergeLuma(b,opacity).MergeChroma(b,opacity)
}
Use:
AVISource("C:\xx.avi")
MaskDeint()
OR if you want Bobbed video:
AVISource("C:\xx.avi")
MaskDeint(bob=true)
Of course you can modify the settings in each deinterlacer to your liking. These are my default settings I like to use.
You will need of course the deinterlacers above [edit]. I get around 23 to 24fps on my P4 3Ghz computer.
[edit]
Regards,
- joshbm
Vectrangle
10th September 2004, 06:11
o.O
I don't know much about deinterlacing, (since the only sources I've dealt with are field shifted pal), but I'm pretty sure that using 4 different filters and averaging the output isn't the best approach.
If you're getting combing, maybe you didn't IVTC properly? Or perhaps you need to tweak thresholds.
If you want to use multiple deinterlacers, it would probably be better to use trim() to separate your video and use the best deinterlacer for each section.
But as I said I don't know much about this area so I could be wrong ^^ We'll see what others think
I'm impressed that you get such high framerates though, I would have thought it would run slower.
Mug Funky
10th September 2004, 07:01
hmm. seems to give pretty good output.
try throwing SangNom into the mix :)
[edit]
it's not really working miracles at my end. perhaps the parity is wrong on one of the deinterlacers? or maybe i'm just unlucky?
joshbm
10th September 2004, 12:12
Hmmmmm....
The output on my end is great, I see no combing, artifacts, or anything sort of distortion or residue from deinterlacing.
joshbm
23rd September 2004, 05:42
Updated with a new script. Input is welcome!
ArabianSwan
18th January 2005, 23:03
I've used the new script but... it does give little flickering sometimes. Encoding time is little bit long.. for a file that takes 3 hours to encode... using this filter it takes about 9 hours ~_~, which I don't mind but if anything could be done to cut the time it would be goooood :D
Other than that... the output is perfect ^_^
scharfis_brain
18th January 2005, 23:17
uhm.. this script looks like brute forcing a 'good' result.
(I didn't tested it)
1) converttoyv12() on interlaced video is a considered bad idea.
it'll give very strange chroma errors.
you have to use interlaced=true in all your chroma conversions!
2) the soften-method will blur the video
IMO, a deinterlacer has to pass-thru the current field without changes, which is not the case, when doing the softening.
Socio
19th January 2005, 01:11
Ok I will bite, what the heck is mice teeth in a image?
Socio
19th January 2005, 02:05
joshbm
Your script does not work with the latest LeakKernelDeint 1.54 you may need to update it.
Guest
19th January 2005, 02:10
Originally posted by Socio
Ok I will bite, what the heck is mice teeth in a image? Combing artifacts, usually along edges.
Socio
19th January 2005, 02:15
Originally posted by neuron2
Combing artifacts, usually along edges.
Ah, ok I get the correlation.
Leak
19th January 2005, 07:57
Originally posted by Socio
Your script does not work with the latest LeakKernelDeint 1.54 you may need to update it.
Yeah, well - you need to put "Leak" in front of the "KernelDeint" and "KernelBob" function calls, but other than that it should work.
Valky
13th February 2005, 22:56
Tomsmocomb line gives me error with default settings, but works if I change it to:
\ .TomsMoComp(0,5,1).LanczosResize(a.width,a.height) : over3
My source was PAL DV
scharfis_brain
16th February 2005, 17:17
Okay.
I've tried out that maskdeint.
It is bad. very bad.
- it destroys chroma. (wrong interlaced handling of yv12)
- this causes chroma judder
- the image is blurry
- the video shows ghosting, cause one of the included deinterlacers is off by one field/frame
joshbm
16th February 2005, 22:47
:eek:... I had forgotten all about this thread lol. I would recommend TDeint() or MVBob(). But if anyone wants to try and fix it with the errors scharfis_brain has described, be my guest :).
scharfis_brain
16th February 2005, 22:53
hehe, I made such mis-deinterlacers, too in past.
just do a search for tmckernelbob :eek:
Didée
16th February 2005, 23:17
Friends, go home. I throw "TomsBobSpecial()" in the race - you have no chance for getting the "strongest afforded misconception" Award :D
joshbm
16th February 2005, 23:23
function MaskDeint(clip a,bool "bob",int "order")
{
soften=default(soften,true)
bob=default(bob,false)
tff=getparity(a)
findOrder=default(order,tff ? 1 : 0)
a=a.ConvertToYV12(interlaced=true)
v1=(bob==false) ? a.KernelDeint(order=findOrder,sharp=false,twoway=false) :
\ a.KernelBob(order=findOrder,sharp=false,twoway=false)
v2=(bob==false) ? a.TDeint(order=findOrder,mode=0,type=2,tryweave=false) :
\ a.TDeint(order=findOrder,mode=1,type=2,tryweave=false)
v3=(bob==false) ? a.SangNom(findOrder,aa=32) :
\ Interleave(a.SangNom(findOrder,aa=32),a.SangNom(Abs(findOrder-1),aa=32))
v4=(bob==false) ? a.ConvertToYUY2().SmoothDeinterlace().ConvertToYV12() :
\ a.ConvertToYUY2().SmoothDeinterlace(tff=tff,doublerate=true).ConvertToYV12()
over1=merge(v1,v3)
over2=merge(v2,v4)
return merge(over1,over2)
}
function merge(clip a,clip b,float "opacity"){
opacity=default(opacity,0.5)
return a.MergeLuma(b,opacity).MergeChroma(b,opacity)
}
What about that scharfis_brain ;).
Regards,
joshbm
scharfis_brain
16th February 2005, 23:24
so then,
I'll go ahead to take over the
"least char count" Avard:
blur(1)
scharfis_brain
16th February 2005, 23:41
this is a correct maskdeint:
function MaskDeint(clip a,bool "bob",int "order")
{
bob=default(bob,false)
tff=getparity(a)
findOrder=default(order,tff ? 1 : 0)
yv12=isyv12(a)
a_yv12=YV12 ? a : a.converttoyv12(interlaced=true)
a_yuy2=YV12 ? a.converttoyuy2(interlaced=true) : a
v1=(bob==false) ? a.leakKernelDeint(order=findOrder,sharp=false,twoway=false) :
\ a.leakKernelBob(order=findOrder,sharp=false,twoway=false)
v2=(bob==false) ? a.TDeint(order=findOrder,mode=0,type=2,tryweave=false) :
\ a.TDeint(order=findOrder,mode=1,type=2,tryweave=false)
v3=(bob==false) ? a_yv12.SangNom(findOrder,aa=32) :
\ Interleave(a_yv12.SangNom(findOrder,aa=32),a_yv12.SangNom(Abs(findOrder-1),aa=32))
v3=yv12 ? v3 : v3.converttoyuy2()
v4=(bob==false) ? a_yuy2.SmoothDeinterlace() :
\ a_YUY2.SmoothDeinterlace(tff=tff,doublerate=true).trim(1,0)
v4=yv12 ? v4.converttoyv12() : v4
over1=merge(v1,v3)
over2=merge(v2,v4)
merge(over1,over2)
}
function merge(clip a,clip b,float "opacity"){
opacity=default(opacity,0.5)
return a.MergeLuma(b,opacity).MergeChroma(b,opacity)
}
- chroma is not altered if not needed
- the frameoffset of smoothdeinterlace is corrected.
now one can see that the average of some deinterlacers will (infortunately) not create the ultimative deinterlacer.
vBulletin® v3.8.11, Copyright ©2000-2025, vBulletin Solutions Inc.