PDA

View Full Version : interlace and filtering


ulfschack
16th August 2002, 09:18
I'm wondering why my script doesn't do what I thought it would do.


LoadPlugin("c:\convolution3d.dll")
a=avisource("c:\clip.avi")
even=a.SelectEven().Convolution3d(0,8,16,0)
odd=a.SelectOdd().Convolution3d(0,8,16,0)
Interleave(even,odd).weave()


I'm trying to seperate the odd and even frames in order to do temporal filtering on frames that are vertically aligned. Then weave them back together. But the final avi is only half vertical resolution.

Happy for any assistance.

Cheers

WarpEnterprises
16th August 2002, 09:25
Weave: This filter has no effect if the clip is already frame-based

so try

Interleave(even,odd).AssumeFieldBased.weave()

ulfschack
16th August 2002, 09:28
Wow! A response time equalling the ping of my v90 modem :)

I'll try it as soon as I get home from work ... thanks.

Belgabor
16th August 2002, 14:17
This might be intentional, but dint you somewhere forget a SeparateFields()?

Cheers
Belgabor

ulfschack
16th August 2002, 15:47
@Belgabor

No, it was intentional. Whether or not it's right is a different matter entirely. I figured that the selectEven/Odd does the seperating as long as the stream isn't assumed to be framebased.

I'm still at work and haven't tried it out yet.

I saw you in another thread concerning this subject, dating all the way back to february. The last suggestion in that thread was something involving quite complicated scripts and TomsMoComp. I'm trying it out as I write, but was inititally more curious about the first suggestions in that thread ... seemed more logical and didn't invole too many plugins either. Did you arrive at any good solution yourself?

cheers

vlad59
16th August 2002, 16:04
Why don't you simply use

SeparateFields
Convolution3d(0,8,16,0)
Weave

ulfschack
16th August 2002, 16:20
@vlad

Well, I don't know much about convolution3d. Just tried it yesterday, but as I understand it it does spatial and temporal filtering at the same time. Now for spatial it might be invariant to the method you suggest, but for temporal I see the following problem:

Two consecutive frames are pictures of (almost) the same object but one line shifted. The algorithm finds a pixel that's way off, it continues to the next frame seeking to identify it there as well, doesn't find it and ends up discarding it as noise. Whereas it might very well have been a present on the frame twice removed (which matches the first vertically) , thus not eligable as noise depending on threshold.

I suspect that too much filtering is done if we can't separate the frames and group the ones that are vertically aligned (odd and even) and temporally filter each sequence before joining them again.

Maybe Convolution3d takes this into account in which case I would be very happy :)

cheers

Belgabor
16th August 2002, 16:41
Originally posted by ulfschack

No, it was intentional. Whether or not it's right is a different matter entirely. I figured that the selectEven/Odd does the seperating as long as the stream isn't assumed to be framebased.


From the AviSynth doc:
SelectEven makes an output video stream using only the even-numbered frames
so you need SeparateFields()

Originally posted by ulfschack

I saw you in another thread concerning this subject, dating all the way back to february. The last suggestion in that thread was something involving quite complicated scripts and TomsMoComp. I'm trying it out as I write, but was inititally more curious about the first suggestions in that thread ... seemed more logical and didn't invole too many plugins either. Did you arrive at any good solution yourself?


I had some troubles with TomsMoComp, but that was due to my own fault. If you set the right frame order (top or bootom first) it performs really well.

Originally posted by ulfschack

Well, I don't know much about convolution3d. Just tried it yesterday, but as I understand it it does spatial and temporal filtering at the same time. Now for spatial it might be invariant to the method you suggest, but for temporal I see the following problem:

Two consecutive frames are pictures of (almost) the same object but one line shifted. The algorithm finds a pixel that's way off, it continues to the next frame seeking to identify it there as well, doesn't find it and ends up discarding it as noise. Whereas it might very well have been a present on the frame twice removed (which matches the first vertically) , thus not eligable as noise depending on threshold.


Afaik you're perfectly right with what you say. Well at least i suspect you'll get some unwanted blending.

To sum it up:
- If you want to preserve interlacing, go the way you proposed. (Adding SeparateFields() ;))
- If you dont, deinterlace first with TomsMoComp (or do ivtc if the source is telecined) and filter afterwards. Well in fact you could try both ways and see whats faster/gives better results, i never tried filtering first and deinterlace after.

Cheers
Belgabor

vlad59
16th August 2002, 16:47
All I can talk about is theory as I never tried filtering an interlaced video so :

I live in France so with PAL system. if you use separatefields on an interlaced source you'll have a 50fps video totally smooth if parity in avisynth is OK.
If you use Selecteven or Selectodd you'll take 1 out of 2 so doing that can cause a big temporal lag between 2 frames if there is a lot of motion.
Instead if you use the 50fps source for filtering, I think you can have more quality.

To check that just open your clip only with separatefields in Vdub and check if there is vertical shift (I don't think there will be).

As I said before, all I wrote is pure theory and can be pure crap.

I thought about interlacing when I programmed convolution3D but I thought that a simple separatefield can solve this problem so I didn't do anything. Just proove me I'm wrong ;) , And I'll add a fix.

ulfschack
16th August 2002, 16:48
I see now the err of my scripting :)

Simply:

LoadPlugin("c:\convolution3d.dll")
a=avisource("c:\clip.avi").AssumeFrameBased().SeparateFields()
even=a.SelectEven().Convolution3d(0,8,16,0)
odd=a.SelectOdd().Convolution3d(0,8,16,0)
Interleave(even,odd).weave()


...then?

(Probably a ConvertToYUY2 first as well)

cheers

Belgabor
16th August 2002, 16:50
Yeah :D

You can probably get away without the AssumeFrameBased(). I never needed it.

Cheers
Belgabor

ulfschack
16th August 2002, 16:52
Sorry vlad ... I submitted a little to late.

Thing is that the avi DOES get jerky if you don't "bob" the fields a quarter pixel up (and down). There are some nice implementations for this in VDub, but it blurs the picture somewhat as I suspect it's some kind of interpolation.

cheers

ulfschack
16th August 2002, 17:04
For speed idea I tried the following (ripped from Ronnylov exept for the Bicubic resize and the borders ... I do this for TV overscan)


LoadPlugin("TomsMoComp.dll")
AviSource("Våren 2002.avi")
Bottom=AssumeFrameBased()
Top=Bottom.SeparateFields.Trim(1,0).weave
Interleave(Bottom.TomsMoComp(0,5,0),Top.TomsMoComp(1,5,0))
#
# Now add filtering on your 50fps progressive video
#
LoadPlugin("Convolution3D.dll")
Convolution3d (0, 8, 16, 0).BicubicResize(720-64,576/2-32).AddBorders(32,16,32,16)
#
# Recreate 25fps interlaced structure
#
Separatefields().SelectEvery(4,0,2).Weave()



TmpgEnc reported 27 hours for 1 hour DV avi (frameserved directly from Premiere). I then switched Convolution3d for Temporalsmoother (in mpeg2dec) and got the time (and probably the quality as well) down to 16 h.

I have P4 2GHz, 512 RDRAM

cheers

vlad59
16th August 2002, 18:48
I know Convolution3D is slow :( :(

I'm optimizing it but I'm afraid it'll be hard to make it faster than temporalSmoother :(

ulfschack
17th August 2002, 01:54
It's a great filter from what I've heard, Vlad. You'll have to compare to temporal AND spatial for any justice in time complexity. I'm gonna use it for sure, but at this instance I was very pressed for time :)

cheers