View Full Version : An Pre-Deinterlace Anime
You Know
23rd July 2004, 12:41
This script make the best choice of field that will go input to whatever deinterlacer producing less blend artifact. Is source is NTSC without blended frame the result are very great
An interlaced video timeline is formed as follow
Let's suppose TFF
Frame.....|.1.|.2.|.3.|.4.|
---------------------------------
Top Field..A...C...E...G......
Bottom.......B...D...F...H....
----------------------------------
where "generally" bottom field is frame ahead
Let's suppose we want deinterlace frame 2 (C-D fields)
Script operate in this manner
check a better bottom field for C beetween B and D
check a better top field for D beetween C and E
match similarity beetween previous choice min( min(sim(C,B), sim(C, D)) , min(sim(D,C), sim(D,E)) )
function AlignTopWithBottomFields(clip c)
{ return c.LanczosResize(c.width, c.height*2) \
.crop(0,1,0,0) \
.LanczosResize(c.width, c.height)
}
function AlignBottomWithTopFields(clip c)
{ return c.LanczosResize(c.width, c.height*2) \
.crop(0,0,0,-1) \
.LanczosResize(c.width, c.height)
}
MPEG2Source("E:\DVDVolume\VIDEO_TS\conan.d2v",idct=4,iPP=true)
AssumeTFF()
ConvertToYUY2(interlaced=true)
SeparateFields()
# ORIGINAL FIELD
ctop2 = SelectEven()
ntop2 = ctop2.DeleteFrame(0).Reverse().DuplicateFrame(0).Reverse()
cbottom2 = SelectOdd()
pbottom2 = cbottom2.DuplicateFrame(0).Reverse().DeleteFrame(0).Reverse()
#ALIGNED FIELD
cbottom = AlignBottomWithTopFields(cbottom2).ConvertToYV12()
pbottom = cbottom.DuplicateFrame(0).Reverse().DeleteFrame(0).Reverse()
ctop = AlignTopWithBottomFields(ctop2).ConvertToYV12()
ntop = ctop.DeleteFrame(0).Reverse().DuplicateFrame(0).Reverse()
# best bottom field for C top field
newbottom = ConditionalFilter(cbottom, pbottom, \
"LumaDifference(ctop, cbottom)", \
"<", \
"LumaDifference(ctop, pbottom)")
newbottom2 = ConditionalFilter(cbottom2, pbottom2, \
"LumaDifference(ctop, cbottom)", \
"<", \
"LumaDifference(ctop, pbottom)")
# best top field for D bottom field
newtop = ConditionalFilter(ntop, ctop, \
"LumaDifference(cbottom, ntop)", \
"<", \
"LumaDifference(cbottom, ctop)")
newtop2 = ConditionalFilter(ntop2, ctop2, \
"LumaDifference(cbottom, ntop)", \
"<", \
"LumaDifference(cbottom, ctop)")
# output the original field not aligned to keep correct interlace
outtop2 = ConditionalFilter(ctop2, newtop2, \
"LumaDifference(ctop, newbottom)", \
"<", \
"LumaDifference(newtop, cbottom)")
outbottom2 = ConditionalFilter(newbottom2, cbottom2, \
"LumaDifference(ctop, newbottom)", \
"<", \
"LumaDifference(newtop, cbottom)")
Interleave(outtop2, outbottom2).AssumeTFF().Weave()
The failure of this script is due use of LumaDifference as estimator.
best top for bottom field (http://wwwstud.dsi.unive.it/~nfalco/doom9/9099fail.jpg)best bottom for top field (http://wwwstud.dsi.unive.it/~nfalco/doom9/9111fail.jpg)
I try to use a Dup thresold for new estimator to use so
float thr = 0
thr = DupThr(top, ptop)
but i do not know if is possible get a value from filter unlike a frame variable.
The number of LumaDifference functions can be reduce of 50% but i experience with linear programming as C++, modula, java or vb and i do not understand rubric's cube FrameEnvaluate chain.
Thease are a couple of example befor and after interlace
KernelDeint(0,threshold=6,twoway=true/false)
9139 -> before (http://wwwstud.dsi.unive.it/~nfalco/doom9/9139.jpg) after (http://wwwstud.dsi.unive.it/~nfalco/doom9/9139post.jpg)
24749 -> before (http://wwwstud.dsi.unive.it/~nfalco/doom9/24749.jpg) after (http://wwwstud.dsi.unive.it/~nfalco/doom9/24749post.jpg)
13806 -> before (http://wwwstud.dsi.unive.it/~nfalco/doom9/13806.jpg) after (http://wwwstud.dsi.unive.it/~nfalco/doom9/13806post.jpg)
for NTSC->PAL converted video
in high motion ~30% artifact removed
in low and mid motion ~ 50% artifact removal
for NTSC source think work really great
scharfis_brain
23rd July 2004, 13:00
hm.. could you provide the original clip, too?
I think, that for standards conversions, restore24 would do the most blend free job...
You Know
23rd July 2004, 13:45
are 2 different things.
This is a script to avoid deinterlace artifact with NTSC source! and do not convert 25 to 24fps or is thinked to remove single field blend. That result with PAL source not bad is only an effect
scharfis_brain
23rd July 2004, 13:50
but how can kerneldeint produce blends IF they are not appearent in the source.
kerneldeint does NOT produce blends itself.
if you get blends after deinterlacing with kerneldeint, the blends are already in the source.
an if you want to remove blends, go for one of the blend-removal-plugins for avisynth or restore24.
so, I want to request the source, again.
lets assume 2:3 pulled down FILM
top A A B C D E E F G
bot a b c c d e f g g
now I want to deinterlace that to 60 fps
what does a normal kernelbob do?
(it looks at the previous field, and compares it with the current one)
frame 1 : a interpolated
frame 2 : Aa weaved
frame 3 : aA weaved
frame 4 : b interpolated, because it sees a difference, to A
frame 5 : bB weaved
frame 6 : c interploated
and so on...
but, my intellibob is much cleverer, it deinterlaces bi-directional:
frame 1 : a interpolated
frame 2 : Aa weaved
frame 3 : aA weaved
frame 4 : bB weaved, because B is the better match than A to b
frame 5 : bB weaved
frame 6 : cC weaved, because C is the better match than B to c
do you search for something like this?
You Know
23rd July 2004, 15:13
yes my intent is that
however the exact term i think is not blend but ghost http://wwwstud.dsi.unive.it/~nfalco/doom9/example.png
i have try intellibob() but it produce a 50 fps and how choose better frame beetween even and odd?
intellibob.selecteven - script above
intellibob.selectodd - script above
http://wwwstud.dsi.unive.it/~nfalco/doom9/intellibob.jpg
PS fps must be 25fps
Didée
23rd July 2004, 15:50
Being the "interlacing impaired" person I just am, I should be quiet here ... but nonetheless:
What you are showing in that sample pic is not ghosting, and it's also not called "blending" in this case. It is "residual combing".
That's what you'll basically get from *every* smart deinterlacer that tries to match & use neighbour fields for deinterlacing, and that is driven by thresholds. Simply because everything that's lying below the threshold is considered as being "the same", and therefore gets weaved together.
To get totally rid of this, the only 100% safe way is to do "dumb" deinterlacing, speak: to interpolate only based of one field, and nothing else. But then, you'll have no residual combing, but jagged edges instead ... and using a smart deinterlacer with threshold=0 gives basically the same.
Perhaps give a try on TomsMoComp. This is the only smart deinterlacer (that I'm currently aware of - it's damn hot here) that is NOT using any thresholds, end even does a - limited - motion search for field matching.
- Didée
You Know
23rd July 2004, 16:16
To get totally rid of this, the only 100% safe way is to do "dumb" deinterlacing, speak: to interpolate only based of one field
yes this may be "accettable" for NTSC source.
Take a one field for example Top for tff you can get 50% quality (some deinterlace call in this manner operate on one field)
But for NTSC-> PAL converted source bottom field can be better that top, so is a lottery use only one frame.
i use kerneldeint because seem be better to avoid residual combined
restore24 make a good work but some people and some work must keep 25fps, so using only intellibob i obtain a 50fps but which frame use (even or odd) is a lottery, because some times are better even some other odd. use full restore24 and deleting
#separatefields.selectevery(4,1,2).weave
#SmartDecimate(24,50, bob=AlreadyBobbed, tel=0.3, t_max=0.0000050, console=false)
trim(24,0) -> trim(25,0)
remain the question which frame use of 50fps
You Know
23rd July 2004, 19:22
i use restore24
MPEG2Source("E:\LUPIN III FILE 1\VIDEO_TS\asd.d2v",idct=4,iPP=true)
AssumeTFF()
ConvertToYUY2(interlaced=true)
a2=r24kernelbob()
b2=intellibob(old=false)
return restore24(a2, b2).ScriptClip("subtitle(string(current_frame))")
if intellibob work as you had explanied choosing most similar frame why in scene switch it fails?
http://wwwstud.dsi.unive.it/~nfalco/doom9/20027.jpg
image on right is obtained with
script in main page
AlignFields(mode=0,ythreshold=20,uvthreshold=15)
Fdecimate(rate=24)
i notice that restore24 some time not interlace
http://wwwstud.dsi.unive.it/~nfalco/doom9/15007.jpg
http://wwwstud.dsi.unive.it/~nfalco/doom9/20027.jpg
r24kernelbob is already by default th=0 so the only thing i tried to correct false interlace was decrease kth of intellibob
#kth=6
#kth=1
kth=0
but no result so i have substituite kerneldeint with alignfields(mode=ord, ythreshold=kth, uvthreshold=3/4*kth) and kth=20 and work better
anyone have idea on better estimator of LumaDifference??
an avisynth delevoper can tell me if can be a filter return a float or other value different as "frame"
qwerpoi
23rd July 2004, 21:30
anyone have idea on better estimator of LumaDifference??
Well, one possible improvement is to use RGBDifference to get the chroma info as well, just convert the clips you are testing to RGB. Note that you do NOT need to convert the input clips, just the test clips (for example, RGBDifference(a.ConvertToRGB(),b.ConvertToRGB()), where a and b were clips in YV12. I'm not sure that will help in this case, though, I think chroma differences are generally small compared to luma.
a avisynth delevoper can tell me if can be a filter return a float or other value different as "frame"
I'm not sure what you are asking for here, but perhaps what you need is to use the ScriptClip() or FrameEvaluate() function instead of ConditionalFilter(). That way you can make as many variables as you need inside the script to be applied to each frame. I don't think the documentation is very clear on this, to see an example of what you can do, check out Leak's blendbob script (http://desdemona.ssw.uni-linz.ac.at/AviSynth/BlendBob.avsi), he has more than 30 lines of code inside his ScriptClip() function.
Leak
23rd July 2004, 21:59
Originally posted by qwerpoi
I'm not sure what you are asking for here, but perhaps what you need is to use the ScriptClip() or FrameEvaluate() function instead of ConditionalFilter(). That way you can make as many variables as you need inside the script to be applied to each frame. I don't think the documentation is very clear on this, to see an example of what you can do, check out Leak's blendbob script (http://desdemona.ssw.uni-linz.ac.at/AviSynth/BlendBob.avsi), he has more than 30 lines of code inside his ScriptClip() function.
Actually, there's a drawback to it - since you need to use global variables you'll have problems if you want to use the function more than once...
I'm just working on a C++ version of my script; since it's using SSE it's quite a bit faster now (though the derainbowing part isn't done yet) and I'm now actually counting how often a specific difference value occurs between two frames and use weighting on it instead of just calculating some max luma differences - and of course I've just found a special case that needed extra treatment, which would have been hard to do in that script.
I hope I'll get to code the derainbowing part tomorrow and do a first release...
np: Four Tet - Unspoken (Rounds)
You Know
23rd July 2004, 22:54
@qwerpoi
i have already try all way buy "internal" function RGBDifference and Chroma butt fails in the situation indicate above, I need a very fast motion estimator as Dup thresold and not use difference of avarange (i think XXXDifference is only a difference beetween avaranges).
But if is not possible draw back to variable a value from a filter whole process must be encored :( so i'am cut out.
thanks for blendbob script
scharfis_brain
23rd July 2004, 23:39
You Know: from your sample pics, I can see, that your function smooths the image a lot, so image information gets lost.
intellibob avoids that.
also, your SOURCE has blends!
there is no doubt. intellibob does not produce blends.
also I accept some residual combing if I can get a much higher overall sharpness.
btw. check the restore24 - revisited thread.
I've updated the script a little bit, so you can no use arbitary decimation ratios:
a=r24kernelbob()
b=intellibob()
restore24(a,b,25,50)
will return a 25fps video, but all belds should be gone.
25:50 is the decimation ratio.
25 final frames/sec : 50 inputted fields/sec (25 frames/sec)
btw: why is 25fps a MUST ?
i notice that restore24 some time not interlace
http://wwwstud.dsi.unive.it/doom9/15007.jpg
http://wwwstud.dsi.unive.it/doom9/20027.jpg
links don't work. what do you mean?
You Know
24th July 2004, 09:49
[duplicate]
You Know
24th July 2004, 09:50
Originally posted by scharfis_brain
You Know: from your sample pics, I can see, that your function smooths the image a lot
the function can not smooth byself only choosing field if you refere pic 20027 on right was kernedeint on right alignfield may be this with a Jpeg compression quality 2 (2/12).
Originally posted by scharfis_brain
also, your SOURCE has blends!
there is no doubt. intellibob does not produce blends.
i never tell intellibob produce blend but if your script should output this sequence
frame 1 : a interpolated
frame 2 : Aa weaved
frame 3 : aA weaved
frame 4 : bB weaved, because B is the better match than A to b
frame 5 : bB weaved
frame 6 : cC weaved, because C is the better match than B to c
in the pics 20027 it have meake a bed choise
frame 2 : Aa weaved
frame 3 : (aB)B weaved
frame 4 : bB weaved
it have failed to recognize most similar B field and use a blended field aB (blend with a=before scenes switch and B=top field after scene switch) instead a clean successive field.
Originally posted by scharfis_brain
also I accept some residual combing if I can get a much higher overall sharpness.
as the title say this is a "An Pre-Deinterlace Anime" and anime must be clean if a have residual combing i must use heavy spatial smoother so dettail get losts. I never wotk with film and i do not result on this. Anime are 12fps -> 24fps so i can work with previous and next field to make a better choise, 90% neighboring is a copy so i can gets losts information due conversion from it.
Films are all 24fps different frame (or not?) i never use with it and i have only anime DVD (R2 :((( ) and we must also pay expensive for a #@$%# video :angry:
btw. check the restore24 - revisited thread.
I've updated the script a little bit, so you can no use arbitary decimation ratios:
a=r24kernelbob()
b=intellibob()
restore24(a,b,25,50)
will return a 25fps video, but all belds should be gone.
25:50 is the decimation ratio.
25 final frames/sec : 50 inputted fields/sec (25 frames/sec)[quote]
good :)
btw: why is 25fps a MUST ?
i notice that restore24 some time not interlace
http://wwwstud.dsi.unive.it/doom9/15007.jpg
http://wwwstud.dsi.unive.it/doom9/20027.jpg
links don't work. what do you mean?
25 fps for 2 reason
1) i have a couple of release ougoing already 25fps so i want maintain same settings. (640x480@25 1700kbps .....)
2) i do not know in deepth as decimation work. Generally decimantion delete a duplicate frame .... how can decide decimation which frame delete of a sequence of duplicate frames? how can establish which frame of duplicate sequence is affected from artifact conversion?? I think it choice always last in the sequence and who can guarantee that last is not the BEST?
now link works... however all image are at http://wwwstud.dsi.unive.it/~nfalco/doom9/
You Know
24th July 2004, 10:04
dear scharfis_brain this is not a competition with your script.
I post because I NEED a suggest to give a better estimator of similarity
using SSIM in cascade only last work and generate output however i can not read informations with conditionread due file format.
when i can get a reasonable estimator next step is discard one of two frame when th > X, with sperance that blended field is detect and not used but replaced with a copy of other (obvious adapted to bottom or top)
scharfis_brain
24th July 2004, 10:05
I can tell you, why intellibob leaves blends passing through:
- it is not intended to remove them
- it just searches the most fitting neighbor for the CURRENT field.
so if the current field is a blend, there is no best neighbor to match on. this means the blend gets interpolated to fullsize.
the combed output of your restore24() was a error of the previous version. it is fixed now.
25 fps for 2 reason
1) i have a couple of release ougoing already 25fps so i want maintain same settings. (640x480@25 1700kbps .....)
I would not see this as a strong reason...
(I assume, you're playing it back on PC?)
2) i do not know in deepth as decimation work. Generally decimantion delete a duplicate frame .... how can decide decimation which frame delete of a sequence of duplicate frames? how can establish which frame of duplicate sequence is affected from artifact conversion?? I think it choice always last in the sequence and who can guarantee that last is not the BEST?
restore24 does NOT use decimate from the decomb package.
it uses smartdecimate, which is cleverer.
decimation IS a MUST, if you want to remove blends effectively...
didée's development versions show, that the decimation and blend removal is now near to perfect. (just waiting for a release:) )
You Know
24th July 2004, 10:13
(I assume, you're playing it back on PC?)
NO all release are SA compatible, however if you have ever release anime on forum you must know that a release of different standard are target as nuked ;)
didée's development versions show, that the decimation and blend removal is now near to perfect. (just waiting for a release:) )
mhm THIS SOUND VERY GOOD
scharfis_brain
24th July 2004, 10:19
I am creating a combmask between two fields
and then comparing this combmask the the previous one.
the combmask with the lesser AVGluma is choosen (this combmask has lesser aere to interpolate -> more image quality)
a simple motionmask,should work, too.
also you could work using masktools logic for combining the masks...
just play around a little bit...
You Know
26th July 2004, 22:44
ok elapsed a few days I have producted an hardcore plugin based on dup thresold as estimator to match field
now i 180° match for both field
PT previous top
CT current top
NT next top
similar for bottom (PB, CB, NB)
it search most similer field for top match and bottom match
PT <- CT -> NT
/ \
PB CB NB
PT CT NT
\ /
PB <- CB -> NB
it seen work not bad deleting a lot of blend field, and less fail to deinterlace.
TODO
fix a prediction on choosing next frame
T1 T2 T3 T4
/ \
B1 B2 B3 -> B4
may be a bad sequence because B4 (bottom field of T4) is temporally ahead respect T4 so you may seen a back step ... i must "fix"
swap to SSIM metod to match field
MPEG2Source("E:\LUPIN III FILE 1\VIDEO_TS\asd.d2v",idct=4,iPP=true)
AssumeTFF()
ConvertToYUY2(interlaced=true)
SeparateFields()
top = selecteven().Crop(0,1,0,0) \
.LanczosResize(720,288).ConvertToYV12()
bottom = selectodd().Crop(0,0,0,-1) \
.LanczosResize(720,288).ConvertToYV12()
newtop = Sim(top, bottom, true, true, true).ConvertToYUY2()
newbottom = Sim(top, bottom, false, true, true).ConvertToYUY2()
#to show field
#return StackVertical( \
# stackhorizontal( \
# stackvertical(newtop, newbottom) , \
# stackvertical(top.subtitle("CT"), bottom.subtitle("CB")) ), \
# stackhorizontal( \
# stackvertical(top.duplicateframe(0).subtitle("PT"), \
# bottom.duplicateframe(0).subtitle("PB")) , \
# stackvertical(top.deleteframe(0).subtitle("NT"), \
# bottom.deleteframe(0).subtitle("NB")) ) \
#)
Interleave(newtop.LanczosResize(720,287).AddBorders(0,1,0,0), \
newbottom.LanczosResize(720,287).AddBorders(0,0,0,1)) \
.AssumeTFF().Weave()
AlignFields(mode=0,ythreshold=15,uvthreshold=10)
remember that some time align top with bottom field can be only 0.5 pixel
Sim(clip top, clip bottom, bool top, bool chroma, bool info)
top = true return top field also bottom
http://wwwstud.dsi.unive.it/~nfalco/doom9/sim.rar
vBulletin® v3.8.11, Copyright ©2000-2026, vBulletin Solutions Inc.