Printable Version of Topic
Click here to view this topic in its original format
Unofficial VirtualDub Support Forums > Avisynth Filtering, Processing and Scripts Discussion > Avisynth Filters


Posted by: cricket Jun 1 2004, 05:01 AM
Hi,
I have been going through the descriptions and parameters of these filters e.g. Levels, Spatialsoften, TemporalSoften for Avisynth2.5 however I was not able to follow the explanations there. Here is one of the links:
http://www.avisynth.org/index.php?page=Levels

Can someone in this forum explain the parameters of these filters in plain English please?

Posted by: i4004 Jun 1 2004, 08:52 AM
no,levels cannot be explained in any language...( smile.gif )

how about trying the 'tweak'?
that's easy to explain....same thing as controls on your tv-set...

these softeners are not ideal....
temporalsoften is worse than temporalsmoother(found in dividee's mpeg2dec.dll)
spatialsoften?uhm....
smartsmootherhiq
or
vaguedenoiser

these filters blur the differences across the frame(spatial) or across a bunch of frames ie on time axis(temporal)

Posted by: cricket Jun 1 2004, 10:05 PM
Surely someone would know about Levels in Avisynth. what I am really trying not to do any processing otherthan encoding in Vdub. As you all know Vdub needs RGB input to use it's filters hence Video:Full Processing Mode where as if I use only Avisynth Filters/plugins I can use Video:fast Recompress which is musch faster than Full Processing Mode...

Posted by: neuron2 Jun 1 2004, 10:44 PM
Be specific about what you don't understand in the documentation. Then we can help you.

Posted by: trevlac Jun 2 2004, 02:04 AM
QUOTE (cricket @ Jun 1 2004, 04:05 PM)
Surely someone would know about Levels in Avisynth. what I am really trying not to do any processing otherthan encoding in Vdub. As you all know Vdub needs RGB input to use it's filters hence Video:Full Processing Mode where as if I use only Avisynth Filters/plugins I can use Video:fast Recompress which is musch faster than Full Processing Mode...

Levels:

Imagine a pixel can have a brightness value from 0-255. 0 being black, and 255 being white. If you tell levels that your input range is 16-235 and you want an output range of 0-255, it will remap your pixels and stretch the range for you.

In effect, this is like lowering the brightness (by 16) and increasing the contrast (by about 1.16 times).

Problem with levels is that it effects the color components (not just the luma). I'd use tweak like i4004 said. Works like the knobs on your tv.

If this is not enough, the VirtualDub internal levels filter works just like the Avisynth one (except you can target luma only). AND Avery was nice enough to supply a help file. smile.gif

Posted by: cricket Jun 2 2004, 05:12 AM
Many thanks Trelac.

And to you Neuron2. I will just first copy how it is explained in Avisynth.org:

Levels(clip input, int input_low, float gamma, int input_high, int output_low,int output_high, bool coring)

The Levels filter adjusts brightness, contrast, and gamma. The input_low and input_high parameters determine what input pixel values are treated as pure black and pure white; the output_low and output_high parameters determine the output values corresponding to black and white; and the gamma parameter controls the degree of nonlinearity in the conversion.


Take another example: The following one is from: Decomb Plugin for Avisynth 2.5
(Version 5.1.1)
Reference Manual
by Donald A. Graft

Telecide(parameter_list)
Commonly used parameters

order (0-1, default none!) defines the field order of the clip. It is very important to set this correctly. The User Manual specifies a reliable procedure for doing so. Use order=0 for bottom field first (bff). Use order=1 for top field first (tff). You must specify order; Decomb throws an exception if you omit this parameter.

guide (0-3, default 0) can be used to improve field matching when the source clip is known to be PAL or NTSC telecined material. To disable this option (blind field matching), set guide=0. For NTSC 24fps->30fps telecine guidance, set guide=1. For simple PAL guidance (tries to maintain lock to the field phase), set guide=2. For NTSC 25fps->30fps telecine guidance, set guide=3.

When this option is enabled, Telecide() can overrule a field match decision and use a predicted match based on the recent clip past and future. The gthresh parameter (below) is used to define how small a discrepancy between the predicted and calculated field matches is required to accept and use the prediction. Do not enable this option unless you know that the source clip corresponds to the selected guidance mode. If in doubt, leave guide=0.

Note that this feature uses Avisynth random frame access, so it works fine when the user uses random timeline navigation.

gthresh (0.0-100.0, default 10.0) defines how large a discrepancy (in percent) between the predicted and calculated field matches is required to reset the pattern. Use the show option, if required, to appropriately tweak this threshold. The show and/or debug output will indicate which matches have been overridden. Overridden matches are denoted with an asterisk, e.g., "in-pattern*".

_______________

I found Donald Graft's explanation much easier to follow. Anyway all what I am trying to say that quite often the Avisynth script explanation is difficult to follow, atlest to me it is difficult.

Many thanks



Posted by: rfmmars Jun 2 2004, 06:22 AM
What I would do for a better understanding of some of Avisynth's topics is to use Virtualdub's same type filters and play with the numbers there to get a feel for a filters. I have been in video for over 30 years, but I too have a problem dealing with alot of the manual pages for Avisynth.

I try to download every script that is posted, and when I have the time, I try them out. As they says "a picture is worth a thousand words" Doing it in VD gives you that picture.

richard
www.photorecall.net

Posted by: cricket Jun 2 2004, 07:40 AM
thanks dude..I am with u on that

Posted by: i4004 Jun 2 2004, 08:54 AM
yes,neuron2...who are you to mess with donald a. graft's stuff anyway?

smile.gif

(somehow i like this 'mild' smileys!)

ps(edit)
QUOTE
As they says "a picture is worth a thousand words"

nope!
these forums say that's not correct,and that poeple like to talk...

i don't like that sentence..never did....
in this example it sucks too;looking at those sliders and image..he won't have a clue what and how are levels working...(not kidding)
but actually reading trevlac's(he said graft's too...although i dunno what does telecide has to do with levels... biggrin.gif ) stuff..).he'll get it ok...

Posted by: Wilbert Jun 2 2004, 09:38 AM
QUOTE
I have been in video for over 30 years, but I too have a problem dealing with alot of the manual pages for Avisynth.

If people just say which manual pages are not clear, we can do something about it. Which ones do you want to see improved?

If I have time I will do something about the levels docs.

Posted by: trevlac Jun 2 2004, 01:35 PM
QUOTE (rfmmars @ Jun 2 2004, 12:22 AM)
What I would do for a better understanding of some of Avisynth's topics is to use Virtualdub's same type filters and play with the numbers there to get a feel for a filters. I have been in video for over 30 years, but I too have a problem dealing with alot of the manual pages for Avisynth.

I try to download every script that is posted, and when I have the time, I try them out. As they says "a picture is worth a thousand words" Doing it in VD gives you that picture.

richard
www.photorecall.net

I think Richad and cricket are being unfair... sad.gif

The AVS doc on levels does tell you to use the Vdub one to learn. In addition, levels is a generic tool that seems to be in many pieces of SW (like Photoshop). I looked what it had to say in the photoshop userguide, and there is no generic description. Just how to mess with the low range, high range, gamma, etc.

If Richard and Cricket would take the time to simply point out some important filters that need clarification, I'm sure this could be done. In fact, Wilbert has already taken a great deal of time to get some documentation for us. wink.gif

Posted by: neuron2 Jun 2 2004, 10:25 PM
Yes, it has been alleged that Donald A. Graft takes extra pains over his documentation. Personally, I find his prose rather stilted and turgid. Each to his own, however.

Posted by: cricket Jun 2 2004, 11:40 PM
Frankly I do not understand the fuss. We all are here to learn and help others and as long as we keep it that way, it becomes an enjoyable experience. By saying that, I have to admit that this is probably one of the most friendly boards I had come across.

One point needs to be considered is that, I am an average user and I did try my level best to understand the explanation of scripts in Avisynth.org and I failed to understand (not all scripts though). And it seems that I am not alone here. By saying this, I do understand that whoever had written the explanation of the scripts, would have spent an enormous amount of time however the point to be mooted here is that the explanations possibley did not have the desired effect. Please try to understand that I am only trying to use Avisynth to it's capacity.

Let's not forget that I still would like to understand the parameters in Levels, Spatialsoften, TemporalSoften filters.

Many thanks

Posted by: trevlac Jun 3 2004, 01:32 AM
@cricket,

At least neuron2 has finally moved from newbie status. Still a long way to self actualization. tongue.gif

The real trouble with your questions are not that you don't understand the doc, but that all you say is "I don't understand." Now I possibly think you are joking if you continue to list Levels as something you don't understand.

So let's take spatial soften ... I may go on and on about filtering theory ... wait ... I don't really know that so your safe. smile.gif But all the ways you could use a filter most certainly fill up a page...

spatial soften

Removes noise by blending pixels in a given frame. Radius is how many sets of surounding pixels. 1 should be 9 including the center, 2 would be 25, 3 would be 49 if my math is correct wink.gif

The difference in luma or chroma must be less than the limit values for the given pixel to be considered in the blending process. I can't say how the blending takes place. Possibly it is a simple average, or maybe a weighted average based upon how far the pixel is away. Also, I'm not sure how chroma values are compared, seeing that chroma has 2 components. They could be added, or a saturation could be determined ... something like U^2+V^2= saturation^2, but I imagine all of those squares would slow things down quite a bit.

Temporal probalby takes the 'same' pixel across frames (forward and back).

I can't really picture the results you get from these ... seeing that I never use them. You should give them a try to get a feel for what you get.

But if you say what you don't understand ... I'm sure people will jump to help you out. smile.gif

[edit]
I took a look at the code and ran it thru bable fish. tongue.gif It seems it takes a normal average. U & V both have to both be within the chroma threshold. meaning color would need to be close which makes sense.

Posted by: rfmmars Jun 3 2004, 03:46 AM
I am not being unfair when I say you can use VD to get a better understanding on how values work in Avisynth.

When you move those sliders with function names, they generate number values. Quickly one can see on the screen what has taken place by changing those values.

VD is live television and AVIsynth is delayed videotape. Once a person has reached a basic understanding though VD, then they can move on to the faster and more flexabe Avisynth.

I hope we are all just having a good time with this but maybe one example per filter with a .JPG insert in the manual might make things a little easier for us non-brainers.

Oh this just in http://forum.doom9.org/showthread.php?s=&threadid=77358

richard

Posted by: trevlac Jun 3 2004, 05:03 AM
Richard,

I am being a little silly (kind of the flavor of this thread), but to quote the avisynth doc on levels:

QUOTE

This is one of those filters for which it would really be nice to have a GUI. Since I can't offer a GUI (at least not in AviSynth's current form), I decided I could at least make this filter compatible with VirtualDub's when the clip is RGB. In that case you should be able to take the numbers from VirtualDub's Levels dialog and pass them as parameters to the Levels filter and get the same results.


So pointing out that the doc is bad and suggesting the same thing it says, is not fair. Well, maybe not exactly the same thing, but that's what I ment. wink.gif

Don't get me wrong. Critical comments about the doc, the filters, the software; are great. Heck, I didn't write any of them so it shouldn't hurt my feelings. Hopefully I gave cricket some info. Hopefully it was right! Maybe he can come back with some more details. I assume there is a reason to know levels, SS, TS. smile.gif

Cheers

Posted by: Wilbert Jun 3 2004, 08:59 AM
I take it that you use the script editor in VdubMod to adjust values of AviSynth scripts. If not, you should try it.

QUOTE
I hope we are all just having a good time with this but maybe one example per filter with a .JPG insert in the manual might make things a little easier for us non-brainers.


Maybe I'm misunderstand you, but there are several examples given in (ok, maybe you want to see more of them)

http://www.avisynth.org/index.php?page=Levels

You can easily try those examples on a clip and see what they do.

Sometimes we add screenshots to a filter description, but it is impossible to add screenshots for every filter (download package will be twice as large).
QUOTE
Oh this just in http://forum.doom9.org/showthread.php?s=&t...&threadid=77358

Someone complaining that levels has no default values smile.gif The docs don't suggest otherwise, so it's purely an implementation issue.

To repeat my question again (besides the filters mentioned in this thread)
QUOTE
If people just say which manual pages are not clear, we can do something about it. Which ones do you want to see improved?


Posted by: rfmmars Jun 3 2004, 01:32 PM
Yes I use Note Book left open when I am adjusting a Avisynth script. I think that we all fail to remember that at one time we were newbies ourselves.

I am in awh with your guys who can write that suff, but some of us just can't grab on to it that easily.

I can design and build at TV station from the bottom up, thats my nitch, but need more help with Avisynth as does Cricket.

richard

Posted by: trevlac Jun 3 2004, 01:48 PM
Does cricket have enough info ...


I didn't want to go on and on. But it is a bunch easier to solve a specific problem than to talk in general terms.

Hopefully he/she was not too intimidated to say his/her specific problem (for fear of sounding dumb). I'd say I sound dumb on about every even post. On the odd ones, I just try to confuse the matter so no one knows what I am talking about. smile.gif

I wanted to vote for the histogram as being the worst documented filter. What the heck do you use 'color mode' for anyway? biggrin.gif

Posted by: cricket Jun 3 2004, 10:53 PM
It's quite amusing to see how an innocent post of mine can create such a constructive (or may be not) dialogues.
For your info trevlac, I am not intimidated. It's only a forum. Frankly if I was intimidated, I would not have been here at the first place. May be it's a good time to go to the root of my problem. Below is the copy of the Levels parametes as in Avisynth:

Levels(clip input, int input_low, float gamma, int input_high, int output_low,int output_high, bool coring)

Now for a lay man like me, it seems that Levels take 7 arguments. However when you go down further, one can see examples such as:

Levels(0, 1, 255, 255, 0)

You see this is where the confusion starts. I believe that Levels take 7 arguments where as in the example it only shows 5. I did test this example on my clip and can see what the filter is doing. Look most of us can do trial and error and figure out what the filter is doing, however while writing an explanation, one should take into account the lowest denominator. I am neither the smartest or the dumbest however by any standard this expression:

Levels(clip input, int input_low, float gamma, int input_high, int output_low,int output_high, bool coring)

still looks like a jargon. I would much prefer the way Donald Graft explains his filters. It may seem very lame to so called specialists, however certainly it will make us beginners life lot easier.

Many thanks all the resposes.

Posted by: neuron2 Jun 4 2004, 02:40 AM
QUOTE (cricket @ Jun 3 2004, 04:53 PM)
I would much prefer the way Donald Graft explains his filters.

Yeah, but who has time for all that? Do you know how much effort it takes to write good documentation? That Graft, sheesh, he must not even have a girlfriend or anything. Ya know? wub.gif

You can omit args at the end of the list. If you do, they take the default values. I'm sure it's documented...somewhere.

Posted by: cricket Jun 4 2004, 04:36 AM
QUOTE
That Graft, sheesh, he must not even have a girlfriend or anything. Ya know?


I believe and many would agree that refering Donald Graft as "That Graft" is very disrespectful. And also it seems you are not answering my query so do not really quite understand why you even bother posting on this particular topic.

Is there someone else who can answer my query please.

Posted by: fccHandler Jun 4 2004, 06:08 AM
QUOTE (cricket @ Jun 4 2004, 12:36 AM)
I believe and many would agree that refering Donald Graft as "That Graft" is very disrespectful.

That Graft is a riot. biggrin.gif

Hint: If you didn't get neuron2's joke, check out his web page at http://neuron2.net/.

Posted by: cricket Jun 4 2004, 07:34 AM
always suspected...

aight

Posted by: trevlac Jun 4 2004, 02:34 PM
@cricket,

All kidding aside ... hopefully I am answering your question. You have a nice fresh perspective and you make the effort to voice it. Made me realize that I have become one of those Avisynth robot zombies that hang around doom9. wacko.gif


I think the root of the confusion is the 'flexible' syntax allowed by Avisynth. That and the fact that there are some nice things that don't have to be provided by the filter programmer. Once

-------------

If an Avisynth Filter accepts a clip as the 1st parameter, this parameter is optional. If the clip is not provided, the 'last' clip in the script is used. Also, a special variable 'last' can be used to refer to this last clip. For example:

CODE

Version()
Levels(0,1,255,0,255, coring=false)

is the same as

myClip=Version()
Levels(myClip, 0,1,255,0,255, coring=false)

is the same as

Version()
Levels(last, 0,1,255,0,255, coring=false)


SOME filters accept named parameters. If the programmer was nice, this makes usage more clear. Named parameters can be used in any order. Unnamed ones must be in the correct order. Levels has 1 named parameter 'coring'.

CODE

This does not work
Levels(input_low=0, gamma=1, input_high=255, output_low=0, output_high=255, coring=true)

This does
Levels(myClip, 0,1,255,0,255, coring=true)

So does this
Tweak(sat=2.0,bright=-20)



SOME filters provide default values for parameters. These parameters are then 'optional'. Levels only has 1 optional parameter. 'coring' who's default value is true.

CODE

Levels(0,1,255,0,255, coring=true)

is the same as

Levels(0,1,255,0,255)

is the same as

Levels(0,1,255,0,255,true)


In the end ... I'd say that neuron is a more thoughtful programmer/designer. IMHO Levels is an example of an (old) poor concept that went everywhere. Like I said, even Photoshop has a levels filter. It is from the perspective of how you change the colors in an image, -vs- what you would really want to do. IE ...How = map the input range to a new output range, -vs- What = make the picture darker, lighter, juice up the colors, change the colors. Tweak in comparison has defaults and names for all of it's parameters. The parameters match what traditional TV adjustments do. Brightness makes the whole picture brighter/darker. Contrast stretches the range from dark to bright. Saturation juices up the colors. Hue changes the colors. BTW: Citizen Graft wrote Tweak. wink.gif



Posted by: Wilbert Jun 4 2004, 11:19 PM
@Trev,

QUOTE
SOME filters accept named parameters. If the programmer was nice, this makes usage more clear. Named parameters can be used in any order. Unnamed ones must be in the correct order. Levels has 1 named parameter 'coring'.


All parameters are named parameters. Also the ones of levels:
CODE

class Levels : public GenericVideoFilter
/**
 * Class for adjusting levels in a YUV clip
**/
{
public:
 Levels( PClip _child, int in_min, double gamma, int in_max, int out_min, int out_max, bool coring,
         IScriptEnvironment* env );

Some of the named arguments are different as the ones in the docs. This can be the case for more filters. But, that doesn't matter. What matters is that the optional named arguments are the same as in the docs.

Posted by: trevlac Jun 5 2004, 12:09 AM
@wilbert,

Those are the internal variable names.

What I was referring to was the parameter names in a script.

Levels(input_low=0, gamma=1, input_high=255, output_low=0, output_high=255, coring=true)

Would be more clear in the doc if the above worked. But it does not, because the filter does not allow you to use names for the parameters.

In the code, this is in some declare thing usually at the bottom of a filter. I'm not at a computer where I can look at any code right now, but IIRC, it looks like ci[input_low]i[gamma]i[input_high] .... b[coring].


As far as 'optional' goes ... Arg[1].int(0) or something like that ... sets the defaults. Not sure if a named param is always optional ...

[edit]

Well it seems that named parameters are optional, but that does not mean there is a default. Also an interesting point. In levels, the values are not checked for any range. You can provide things like 999.

I made a levels filter to test this all. http://trevlac.us/wilbert/levelsX.rar

The params are now all named (optional). However, I do not default the input_low. It seems to get a big value (probably what is in the memory spot.) Others are defaulted to "do nothing" values. Usage LevelsX(input_low=0).

Posted by: cricket Jun 5 2004, 01:22 PM
thank you all guys..I am sure by looking at number of visits to this particular post, I am sure many of us a bit more enlightened now.

Appreciated..

Powered by Invision Board (http://www.invisionboard.com)
© Invision Power Services (http://www.invisionpower.com)