Log in

View Full Version : KernelDeinterlacer ghosting....


Human_USB
3rd January 2004, 13:29
Hello,

I've been trying to rip some animes I own and deinterlacing them is killing me. I been searching the forums and I hear from people that KernelDeint is the best at deinterlacing animes. SO, I tryed it and I get ghost like errors. Also the lines in the anime become jaggy, but I got that problem with other deinterlacers. I used the setting KernelDeint(order=1,twoway=true,threshold=5) in this image.

http://animepenguin.web1000.com/doom9/1.png

Am I doing something wrong or am I going to just have to live with the errors?

Thanks
-Jason

scharfis_brain
3rd January 2004, 13:37
I cannot see any ghosting on your image!

but kerneldeint is know for making some ghosts, because of its spatio-temporal-interpolation kernel.

If you want a deinterlacer that doesn't produce jaggy lines, you may want to try this function, I am currently working with:

function TMCkernelbob(clip input, int "th", bool "TFF")

{
function kernelbob(clip a, int th, int ord)
{
f=a.kerneldeint(order=ord, sharp=false, twoway=false, threshold=th)
e=a.separatefields.trim(1,0).weave.kerneldeint(order=1-ord, sharp=false, twoway=false, threshold=th)
interleave(f,e)
}


th = default(th,7)
input = (TFF == true) ? input.assumetff.addborders(0,4,0,4) : input.assumebff.addborders(0,4,0,4)
input = input.converttoyuy2(interlaced=true)

x=input.separatefields.selecteven.tomsmocomp(0,-1,0).separatefields.selectodd
y=input.separatefields.selectodd.tomsmocomp(0,-1,0).separatefields.selecteven
a=interleave(x,y).weave.swapfields.kernelbob(th,0).crop(0,0,0,-1).addborders(0,1,0,0)
#select TMC's extra-lines and deinterlace them

b=input.kernelbob(th,0)
#take the input clip and deinterlace it

layer(a,b,"fast").crop(0,4,0,-4)
#mix both to get a higher resolution

blur(0,-1)
#restore the sharpness lost due to the mixing
}

you'll need kerneldein140.dll and tomsmocomp.dll

and also have a look at this thread: http://forum.doom9.org/showthread.php?s=&threadid=66540

Human_USB
3rd January 2004, 13:52
Thanks for the reply..... I tested your coded but the video is still interlaced.

As for the ghosting I maybe using the wrong wording. I updated the image with a arrow to show what I'm talking about

http://animepenguin.web1000.com/doom9/2.png

You see her hand at the top of the frame..... it's also at the center in orange. In the dvd it's not like that, so I must be a error of the deinterlacer or the codec. And I've never had this problem with XVID before.

Thanks
-Jason

scharfis_brain
3rd January 2004, 14:00
Thanks for the reply..... I tested your coded but the video is still interlaced.
Did you set the TFF - Parameter correctly?
also try lowering the th- value...

You see her hand at the top of the frame..... it's also at the center in orange. In the dvd it's not like that, so I must be a error of the deinterlacer or the codec. And I've never had this problem with XVID before.

Pleas up a non-deinterlaced image for comparing....

I cannot see any wrong things..

Human_USB
3rd January 2004, 14:14
ok....

Image one;
Deinterlaced (http://animepenguin.web1000.com/doom9/2.png)

Image two;
Interlaced (http://animepenguin.web1000.com/doom9/3.png)


As for the setting in your code..... I don't see what to change. Sorry. I'm still learning scripting.


Thanks
-Jason.

scharfis_brain
3rd January 2004, 14:49
okay

for kerneldeint do the following:

mpegsource("file.d2v")
converttoyuy2(interlaced=true)
kerneldeint(yourparamters)

for my deinterlacing function do something like this:

copy everything in the code-tag of my post above into a file called tmckernelbob.avs

then make a new avs with following content:
loadplugin("kerneldeint140.dll")
loadplugin("tomsmocomp.dll")
import("tmckernelbob.avs")

xxxsource("yourvideo.xxx")
tmckernelbob(TFF=false) #set TFF=true if output is weird

Human_USB
3rd January 2004, 16:18
Thank you,

Both worked great.... all though you code make the final movie large but I can live with that. I have one more question. Will this script work right?


SetWorkingDir("C:\Filters\")
LoadPlugin("mpeg2dec3.dll")
Loadplugin("kerneldeint140.dll")

mpeg2source("C:\DVD\Rips\FLCL\flcl-non.d2v")
trim(8000,8720)

##Deinterlacing
import("C:\Filters\kerneldeint.avs")

crop(4,2,712,476)
LanczosResize(640,480)


and kerneldeint.avs being


converttoyuy2(interlaced=true)
kerneldeint(order=1,twoway=true,threshold=5)


Oh, one more thing. The above was without forcefilm but if I forcefilm I get the ghost like errors again.

http://animepenguin.web1000.com/doom9/forcefilm.png

Thanks
-Jason

Leak
3rd January 2004, 18:28
Originally posted by Human_USB

converttoyuy2(interlaced=true)
kerneldeint(order=1,twoway=true,threshold=5)



Hmmm... exactly why are you using "twoway=true"? AFAIK that's even more prone to give you blends as it'll take information both from the previous and the next frame when interpolating.

Also, you could try this with your clip; I'm using it for Last Exile and it's given me better results than a simple Telecide/Decimate on frames where the Telecide/Decimate-combo would also produce such color-ghosting:


Function KernelBob(clip a, int topFieldFirst, int kernelDeintThreshold)
{
a=((topFieldFirst == 1) ? a.AssumeTFF() : a.AssumeBFF())

b=separatefields(a).trim(1,0).weave()

a=a.kerneldeint(order=TopFieldFirst, sharp=false, threshold=KernelDeintThreshold)
b=b.kerneldeint(order=(1-TopFieldFirst), sharp=false, threshold=KernelDeintThreshold)

return interleave(a,b)
}

Function BlendBob(clip c, bool show)
{
a=c.AssumeFieldBased().Trim(1,0)
b=c.AssumeFieldBased()

global a1=a.SelectOdd()
global a2=a.SelectEven()

global b1=b.SelectOdd()
global b2=b.SelectEven()

# Poor man's blending of 2 fields... :)

global aw=a.Weave.BilinearResize(a.Width,a.Height)
global bw=b.Weave.BilinearResize(b.Width,b.Height)

global aw=(show == false ? aw : aw.Subtitle("a"))
global bw=(show == false ? bw : bw.Subtitle("b"))

result=ScriptClip(c.AssumeFPS(c.Framerate/2),"
ad=Subtract(a1,a2)
bd=Subtract(b1,b2)

# Just one metric turned out to be not quite enough so I
# calculate 5 of them and let the majority decide

global diff1=YPlaneMinMaxDifference(ad, 2)-YPlaneMinMaxDifference(bd, 2)
global diff2=YPlaneMinMaxDifference(ad, 5)-YPlaneMinMaxDifference(bd, 5)
global diff3=YPlaneMinMaxDifference(ad,10)-YPlaneMinMaxDifference(bd,10)
global diff4=YPlaneMinMaxDifference(ad,20)-YPlaneMinMaxDifference(bd,20)
global diff5=YPlaneMinMaxDifference(ad,50)-YPlaneMinMaxDifference(bd,50)

pos=0
neg=0

pos=pos+(diff1 >= 0 ? 1 : 0)
pos=pos+(diff2 >= 0 ? 1 : 0)
pos=pos+(diff3 >= 0 ? 1 : 0)
pos=pos+(diff4 >= 0 ? 1 : 0)
pos=pos+(diff5 >= 0 ? 1 : 0)

neg=neg+(diff1 < 0 ? 1 : 0)
neg=neg+(diff2 < 0 ? 1 : 0)
neg=neg+(diff3 < 0 ? 1 : 0)
neg=neg+(diff4 < 0 ? 1 : 0)
neg=neg+(diff5 < 0 ? 1 : 0)

(pos < neg ? aw : bw)

(" + String(show) + " == false ? last : \\
Subtitle( \\
chr(32) + chr(32) + chr(32) + chr(32) + \\
String(diff1) + chr(32) + \\
String(diff2) + chr(32) + \\
String(diff3) + chr(32) + \\
String(diff4) + chr(32) + \\
String(diff5)))
")

return result.AssumeFrameBased()
}

a=...
a=a.KernelBob(1,8)
a=a.BlendBob(false)


What this does is use a bob filter (you don't need to use KernelBob if you don't want to) to deinterlace the video and then always blends a frame either with the previous or next frame (whichever has less maximum luma difference when both are subtracted) to get rid of the doubled framerate a bob produces. It might produce a blended frame here and there on scene-changes (where it's not really noticeable) but unless the bob was really misconfigured you shouldn't get any combing as you get with Telecide when you set the vthresh too high - it doesn't even need a threshold... :)

(Okay, so if the difference between the 2 frames to choose from is really, really small it might choose the wrong one, but I prefer, say, blended mouth-flaps to combed ones any day of the week...)

Also, you can just use Decimate(cycle=5) on it's output if the video has been telecined - works great. (Dunno if FLCL is 24 or 30 FPS - can you say "anime DVD backlog"? :) - but if it is 24 you should probably decimate it...)

I guess I should make a C++ version of it someday, as you could probably do the 10 YPlaneMinMaxDifferences with only analyzing the image 2 times instead of 10, but it's fast enough for me. :)

np: Danger Mouse & Jemini - Bush Boys (Ghetto Pop Life)

Human_USB
3rd January 2004, 18:48
I was using twoway because I was still test kerneldeinterlacer.... :D I will try your deinterlacer once my encoding is done. BTW, is last Exile any good? I've been wanting to watch it.

Leak
3rd January 2004, 19:06
Originally posted by Human_USB
I was using twoway because I was still test kerneldeinterlacer.... :D I will try your deinterlacer once my encoding is done. BTW, is last Exile any good? I've been wanting to watch it.

It's *very* good (at least that's my opinion after having seen the first disc), but there's still 2 months to go till the next DVD comes out... :(

I suck at reviews, but this sums it up quite nicely:

http://www.animeondvd.com/reviews2/disc_reviews/2464.php

(Still, I've already thought about LARTing the one that was responsible for the sequences where they probably took >30FPS video and used blend decimation to get it down to 30FPS - those scenes don't even look smooth on my TV, and of course they don't get better after being decimated, even though using mode=3 helps somewhat. I mean, most of these scenes were rendered anyhow - how hard can it be to render them with 24FPS in the first place? :angry: )

np: T.Raumschmiere - Zartbitter (The Great Rock'n'Roll Swindle)

Human_USB
3rd January 2004, 20:59
well.... if you want a good anime watch RahXephon..... I also had a problem with that one because it's 24/30fps, but it makes up for that because it's a great anime.

Leak
3rd January 2004, 21:10
Originally posted by Human_USB
well.... if you want a good anime watch RahXephon..... I also had a problem with that one because it's 24/30fps, but it makes up for that because it's a great anime.

Well, I guess I won't as I have a big enough backlog already and also I loathe shows with giant mecha in them - thanks for the tip, though. :)

np: Danger Mouse & Jemini - The Only One (Ghetto Pop Life)

Human_USB
3rd January 2004, 21:19
The show is more about the people and not the mechs...... It's more of a NGE with a better ending. RahXephon has one of the oddest storys out there. Read the AnimeonDVD review of it but don't read the story part of the review!!! It's not just a mech show..... and yes I get bored of of animes doing "Big mech vs Bigger Mechs" AKA Gundam. Oh, most (maybe all) of ADV's dvds are 24/30 so I've been having loads of fun beause I own Excel Saga (24/30), Kenshin (24/30) and so on.

Tri
4th January 2004, 14:39
At the beginning of the first FLCL episode the camera is moving from the bridge to the factory which then emits some steam.

There is appearently something horribly wrong with the fields, so I ask what you did about this part?

Human_USB
4th January 2004, 15:20
I have no problems with


converttoyuy2(interlaced=true)
kerneldeint(order=1,twoway=true,threshold=5)


-Jason

Tri
4th January 2004, 16:28
Now I used this:
Telecide(order=1,post=0,hints=true)
kerneldeint(order=1,twoway=true,threshold=5)
Decimate(5)
It came it out clean this time, very different to my experiments some months ago. :) Thanks.

Mug Funky
4th January 2004, 16:53
HE'S DEAD! this young boy is completely dead just as Taro would be!
(but he's not taro-kun...)

fek, i love that show.

yeah, it's 30p + 24p. a real bitch in PAL land i can tell you.

i wrote my "funkybob" script (kinda like kernelbob but slow as hell) especially for FLCL.

but i'm happy to just watch the nice little box set on my TV where i can't see the blends (but i see pixellated lines).

i even have the (P!) sticker on my car... hehehe.

@ Human_USB:

Excel Saga is actually 24p + 30i... that's a bad one in PAL land as well. esp. that sped up bit in the intro ("tonzura koite!") where there simply aren't any not-blended frames to recover.

Human_USB
4th January 2004, 17:41
I think all of ADVs dvds are like that.... So the Uk versions are just like the US one. I would post a clip are two but dial up is a pain. If someone can give me a ftp that has resume I would post them.

Aktan
5th January 2004, 04:51
So wait i'm confused. This FLCL is not from the US DVDs?

Human_USB
5th January 2004, 15:10
No..... the FLCL I was being helped with was NTSC non-force film.

Aktan
6th January 2004, 10:11
I should have said this before, but I have encoded the US release of FLCL and I used the filter IT.dll to deinterlace. IT.dll deinteralced it perfectly so I wanted to recommend that filter to you.

Human_USB
6th January 2004, 17:14
Can you post your setting..... becuase I'm always wanting to learn.



Thanks
-Jason

Aktan
7th January 2004, 09:38
The default settings for IT.dll worked fine. As in:


IT()

Human_USB
7th January 2004, 15:49
Thanks..... I worked great.

Mug Funky
8th January 2004, 15:11
sorry for the off topic post here...

@ Human_USB:

you spelt "chaos" wrong in your sig... thought i'd let you know :D

Human_USB
8th January 2004, 15:22
Yeah I did..... I never saw that. Thanks man


:eek:


Thats what I get if I work at night and post in the day.