Log in

View Full Version : InterlacedSmoothing-how to apply filter in this function


Serbianboss
7th December 2006, 14:57
This is Original function from avisynth site:


This applies any filter to an interlaced source.
The filter can be used for both spatial filters, like blur() and temporal filters like temporalsoften.

function ApplyInterlacedFilter(clip v1, string filter) {

v2 = separatefields(v1)
selecteven(v2)
even = Eval(filter)
selectodd(v2)
odd = Eval(filter)
interleave(even,odd)
return weave()

}


I try but i get error invalid argument to function Applyinterlaced filter. How to proper setup for example with degrainmedian filter

krieger2005
7th December 2006, 15:18
ApplyInterlacedFilter(yourClip,"DeGrainMedian(ValY,ValUV,mode=X)") should do the job.

Serbianboss
7th December 2006, 15:38
I try before that but without success

v1=AVISource("C:\Documents and Settings\Nenad\Desktop\film.avi")

function ApplyInterlacedFilter(clip v1, string filter) {

v2 = separatefields(v1)
selecteven(v2)
even = Eval(degrainmedian (limitY=5,limitUV=7,mode=0) )
selectodd(v2)
odd = Eval(degrainmedian (limitY=5,limitUV=7,mode=0) )
interleave(even,odd)
return weave()

}

ApplyInterlacedFilter(v1, "degrainmedian(limitY=5,limitUV=7,mode=0)")


OR if i set like this i get error Invalid arguments to function "Eval"

Serbianboss
7th December 2006, 15:42
Hm, i succeed if i delete Eval(from evan and odd) but i dont know does this is ok ?

So it looks like(without evan):



v1=AVISource("C:\Documents and Settings\Nenad\Desktop\film.avi")

function ApplyInterlacedFilter(clip v1, string filter) {

v2 = separatefields(v1)
selecteven(v2)
even = (degrainmedian (limitY=5,limitUV=7,mode=0) )
selectodd(v2)
odd = (degrainmedian (limitY=5,limitUV=7,mode=0) )
interleave(even,odd)
return weave()

}

ApplyInterlacedFilter(v1, "degrainmedian(limitY=5,limitUV=7,mode=0)")

acrespo
7th December 2006, 16:21
No, you need this:

v1=AVISource("C:\Documents and Settings\Nenad\Desktop\film.avi")

function ApplyInterlacedFilter(clip v1, string filter) {

v2 = separatefields(v1)
selecteven(v2)
even = (filter )
selectodd(v2)
odd = (filter)
interleave(even,odd)
return weave()

}

ApplyInterlacedFilter(v1, "degrainmedian(limitY=5,limitUV=7,mode=0)")

or

v1=AVISource("C:\Documents and Settings\Nenad\Desktop\film.avi")

function ApplyInterlacedFilter(clip v1) {

v2 = separatefields(v1)
selecteven(v2)
even = degrainmedian(limitY=5,limitUV=7,mode=0)
selectodd(v2)
odd = degrainmedian(limitY=5,limitUV=7,mode=0)
interleave(even,odd)
return weave()

}

ApplyInterlacedFilter(v1)

stickboy
7th December 2006, 17:55
Hm, i succeed if i delete Eval(from evan and odd) but i dont know does this is ok ?Technically, it does work, but it defeats the point of using the ApplyInterlacedFilter. That change makes ApplyInterlacedFilter no longer general (you can't use it with anything other than DegrainMedian), redundant and misleading (the "filter" argument is no longer used), and kind of pointless as a separate function.

Serbianboss
7th December 2006, 23:24
Technically, it does work, but it defeats the point of using the ApplyInterlacedFilter. That change makes ApplyInterlacedFilter no longer general (you can't use it with anything other than DegrainMedian), redundant and misleading (the "filter" argument is no longer used), and kind of pointless as a separate function.

Can you post proper function with eval. I try but have error "Invalid arguments to function Eval"
So scirpt which post acrespo isnt good because "Eval" is missing?



v1=AVISource("C:\Documents and Settings\Nenad\Desktop\film.avi")


function ApplyInterlacedFilter(clip v1, string filter) {

v2 = separatefields(v1)
selecteven(v2)
even = Eval(degrainmedian)
selectodd(v2)
odd = Eval(degrainmedian)
interleave(even,odd)
return weave()

}

ApplyInterlacedFilter(v1, "degrainmedian(limitY=5,limitUV=7,mode=0)")

stickboy
7th December 2006, 23:34
The proper function is how it originally was; you shouldn't change it.

The Eval() lines should say:
Eval(filter)notEval(degrainmedian)

Serbianboss
7th December 2006, 23:46
It works now.

So script is:


last=AVISource("C:\Documents and Settings\Nenad\Desktop\film.avi")


function ApplyInterlacedFilter(clip v1, string filter) {

v2 = separatefields(v1)
selecteven(v2)
even = Eval(filter)
selectodd(v2)
odd = Eval(filter)
interleave(even,odd)
return weave()

}

ApplyInterlacedFilter(last, "degrainmedian(limitY=5,limitUV=7,mode=0)")


Just one more: Can this function be used to apply two filters. For example degrainmedian and peachsmoother or fft3d...

stickboy
8th December 2006, 01:57
Sure. Do:
ApplyInterlacedFilter(last, "degrainmedian(limitY=5,limitUV=7,mode=0)")
ApplyInterlacedFilter(last, "PeachSmoother(...)")
ApplyInterlacedFilter(last, "fft3d(...)")
or even:
ApplyInterlacedFilter(last, "degrainmedian(limitY=5,limitUV=7,mode=0).PeachSmoother(...).fft3d(...)")
BTW, passing "last" as the first argument isn't necessary; AviSynth does it automatically if needed. For example:
ApplyInterlacedFilter("degrainmedian(limitY=5,limitUV=7,mode=0)")
ApplyInterlacedFilter("PeachSmoother(...)")
ApplyInterlacedFilter("fft3d(...)")

IanB
8th December 2006, 03:17
Ouch! Bad Stickboy! Teach people how to be slow!...
SeparateFields()
Weave()
SeparateFields()
Weave()
SeparateFields()
Weave()
...Try thisApplyInterlacedFilter(
\ "degrainmedian(limitY=5,limitUV=7,mode=0)." +
\ "PeachSmoother(...)." +
\ "fft3d(...)" )

stickboy
8th December 2006, 05:30
Ouch! Bad Stickboy! Teach people how to be slow!...
SeparateFields()
Weave()
SeparateFields()
Weave()
SeparateFields()
Weave()
...Yeah, I know, but premature optimization and all that. Easier to show people some basics and then ease them into optimization techniques.
Try thisApplyInterlacedFilter(
\ "degrainmedian(limitY=5,limitUV=7,mode=0)." +
\ "PeachSmoother(...)." +
\ "fft3d(...)" )Hey, now, I did say that!

Fizick
8th December 2006, 05:34
generally, I thin that it is very bad idea to use and teach others how to use three (and even two) temporal filters, especially with Peach (read its doc).
Bad stickboy and IanB :)

Serbianboss
8th December 2006, 10:24
Why this way is bad to apply two or more filters:


ApplyInterlacedFilter("degrainmedian(limitY=5,limitUV=7,mode=0)")
ApplyInterlacedFilter("PeachSmoother(...)")
ApplyInterlacedFilter("fft3d(...)")




So if that way is bad does is than better to work with this:


ApplyInterlacedFilter(
\ "degrainmedian(limitY=5,limitUV=7,mode=0)." +
\ "PeachSmoother(...)." +
\ "fft3d(...)" )



generally, I thin that it is very bad idea to use and teach others how to use three (and even two) temporal filters, especially with Peach (read its doc).


Than does is better for example to use one Spatial or Spatiotemporal and one temporal.

For example Degrainmedian or FFT3d or Vague denoiser(this is just spatial) with Temporal cleaner ?

krieger2005
8th December 2006, 17:12
Why this way is bad to apply two or more filters:


ApplyInterlacedFilter("degrainmedian(limitY=5,limitUV=7,mode=0)")
ApplyInterlacedFilter("PeachSmoother(...)")
ApplyInterlacedFilter("fft3d(...)")
There is nothing bad but it is timeconsuming, so slowing down the script because the movie will be Weaved and Separated 3 times. I thinks it consumes also much memory.

Than does is better for example to use one Spatial or Spatiotemporal and one temporal.

For example Degrainmedian or FFT3d or Vague denoiser(this is just spatial) with Temporal cleaner ?I don't know why fizick suggested not to use different temporal-cleaner. maybe i missed one of the "Big" How-To-Clean-A-Clip Rules. In genereal (i said this in one of the previous thread of you) you should look if it look good for you! Every Script and every filter has its pros and cons for different movies. Many peaple ask here for a good script but they also give a short clip.

Serbianboss
9th December 2006, 10:07
There is nothing bad but it is timeconsuming, so slowing down the script because the movie will be Weaved and Separated 3 times. I thinks it consumes also much memory.


So if this is slow that this method would be better(less time consuming) One apply interalced filter and with + add more filters.


ApplyInterlacedFilter(
\ "degrainmedian(limitY=5,limitUV=7,mode=0)." +
\ "PeachSmoother(...)." +
\ "fft3d(...)" )


One more, can in this function can be added limitedsharpen faster filter ?

krieger2005
9th December 2006, 12:06
So if this is slow that this method would be better(less time consuming) One apply interalced filter and with + add more filters.


ApplyInterlacedFilter(
\ "degrainmedian(limitY=5,limitUV=7,mode=0)." +
\ "PeachSmoother(...)." +
\ "fft3d(...)" )

Exactly.
One more, can in this function can be added limitedsharpen faster filter ? You can add as much filter as you want. for more filter i would build an own function, so something like this:

avisource()/mpeg2source()
ApplyInterlacedFilter("OwnFunction")



function OwnFunction(clip c){
c
Functioncall-1-on-your clip
Functioncall-2-on-your clip
...
Functioncall-n-on-your clip
} Especially in your case "OwnFunction" would look like:function OwnFunction(clip c){
c
degrainmedian(limitY=5,limitUV=7,mode=0)
PeachSmoother(...)
fft3d(...)
LimitedSharpenFaster(...)
}So exactly as normal code, but now you can call your funaction n time when you add to your Code the call "OwnFunction" (BTW: OwnFUnction is a free name. You can use your own name. But to call that function you must call that name). The function must get a clip (c is then the variable. You can see this as c=avisource(..), so it could be every other name: X,Y Z,Abrakadabra,...) and other parameters. There is more about in the avisynth-dokumentation... For your case here this simple function would work well.

foxyshadis
9th December 2006, 23:34
Not that there will be anything left to sharpen after that... [/ot]

Serbianboss
11th December 2006, 14:07
Sorry for late answer.

Does this way is ok:


last=AVISource("C:\Documents and Settings\Nenad\Desktop\film.avi")
loadplugin("mt_masktools.dll")
import("C:\Program Files\AviSynth 2.5\plugins\limitedsharpenfaster.avs")


function ApplyInterlacedFilter(clip v1, string filter) {
v2 = separatefields(v1)
selecteven(v2)
even = Eval(filter)
selectodd(v2)
odd = Eval(filter)
interleave(even,odd)
return weave()

}

ApplyInterlacedFilter("OwnFunction")

function OwnFunction(clip c){
c
degrainmedian(limitY=5,limitUV=7,mode=0)
PeachSmoother()
fft3dfilter()
LimitedSharpenFaster(smode=4,strength=100)
}


Does this is ok or no ? Here are two functions. First InterlacedSmoothing and second Ownfunction.

thanks

krieger2005
11th December 2006, 14:31
1. A general suggestion: Don't mix functions and the script. Put the functions above or at the buttom of the script. My sugestion: at the buttom.
2. Load the Plugins before the script. The best Place for loading of Plugins is: first! Then import of external Scripts. Then load of your movie. Then your script. Then your functions.
3. Add at the End of the script a "return last" or something similar. This is not that important but help to read you scripts.
4. last=: You don't need to do that this way. "last" is a general variable in avisynth where it save the last movie in. so:
last=avisource(...) should be equal to avisouce(...)


Now your code, i will do my own suggestion above (to understand, what you made):
loadplugin("mt_masktools.dll")
import("C:\Program Files\AviSynth 2.5\plugins\limitedsharpenfaster.avs")

# --------------- SCRIPT ---------------
AVISource("C:\Documents and Settings\Nenad\Desktop\film.avi")

Assume?FF() # You should replace ? by B or T
ApplyInterlacedFilter("CleanMyMovie")

return last

# ---------- FUNCTIONS ----------
function ApplyInterlacedFilter(clip v1, string filter) {
v2 = separatefields(v1)
selecteven(v2)
even = Eval(filter)
selectodd(v2)
odd = Eval(filter)
interleave(even,odd)
return weave()
}

function CleanMyMovie(clip c){
c
degrainmedian(limitY=5,limitUV=7,mode=0)
PeachSmoother()
fft3dfilter()
LimitedSharpenFaster(smode=4,strength=100)
}This way it should work okey.

Didée
11th December 2006, 14:43
Random comment:

Applying a sharpening filter to fieldseparated video carelessly may show unwanted sideffects ... pronounced shimmering, pronounced aliasing, etc.

Serbianboss
11th December 2006, 14:47
It works. Script above also work but it was mixed with functions.

I have few question:

1. Does is necessary to put AssumeBFF(). I mean why is this important in this script? (my source is pal interlaced so its BFF)

2. Does "return last" is necessary in this script?

3. The most important question: I use limitedsharpen faster in this script. And i know that limited sharpen work only on progressive source not on interlaced. So is this correct way to put LSF in this script ?

thanks

krieger2005
11th December 2006, 15:34
2. Does "return last" is necessary in this script? It is not neccessary, as i wrote before.

3. The most important question: I use limitedsharpen faster in this script. And i know that limited sharpen work only on progressive source not on interlaced. So is this correct way to put LSF in this script ?Technically it is ok. But as Didée wrote the usage of Sharpener like LSF filedwise have several negative effects. I think this effects does not look that bad on a bobbed Video, right Didée?

Serbianboss
11th December 2006, 23:25
usage of Sharpener like LSF filedwise have several negative effects.


So, it appears that LSF cannot properly to use on fieldwiser video.
My goal was to make some function(interlaced smoothing) which can use LSF but not to bobbed video.

Can some sharpen filter be used on fieldwise video in interlacedsmoothing function but not to bob video:


loadplugin("mt_masktools.dll")
import("C:\Program Files\AviSynth 2.5\plugins\limitedsharpenfaster.avs")

# --------------- SCRIPT ---------------
AVISource("C:\Documents and Settings\Nenad\Desktop\film.avi")

Assume?FF() # You should replace ? by B or T
ApplyInterlacedFilter("CleanMyMovie")

return last

# ---------- FUNCTIONS ----------
function ApplyInterlacedFilter(clip v1, string filter) {
v2 = separatefields(v1)
selecteven(v2)
even = Eval(filter)
selectodd(v2)
odd = Eval(filter)
interleave(even,odd)
return weave()
}

function CleanMyMovie(clip c){
c
degrainmedian(limitY=5,limitUV=7,mode=0)
PeachSmoother()
fft3dfilter()
LimitedSharpenFaster(smode=4,strength=100)
}

Serbianboss
12th December 2006, 19:38
Any sharpen filter which can use in this function?