Home
RecentChanges

Search:

» AviSynth is a powerful video FrameServer for Win32.

AviSynth Links:
»Download
»Learn to script
»FAQ
»Manual
»Discussion fora
»Project page
»External filters
»FeedBack

» You can add pages to this website immediately. No login required.
Edit this document

» AboutAviSynth

 

Avisynth 
Logo

Levels

( Diese Seite in flag-germany.gif Deutsch )

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. To be precise, the conversion function is:

output = [(input - input_low) / (input_high - input_low)]1/gamma (output_high - output_low) + output_low

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. 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.

When processing data in YUY2 mode, Levels only gamma-corrects the luma information, not the chroma. Gamma correction is really an RGB concept, and I don't know how to do it properly in YUY2. However, if gamma = 1.0, the filter should have the same effect in RGB and YUY2 modes.

In v2.53 an optional coring = true/false (true by default, which reflects the behaviour in older versions) is added. When setting to true is means that the luma (Y) is clipped to [16,235], and when setting to false it means that the luma is left untouched.

Examples:

# does nothing on a [16,235] clip, but it clips (or "clamps") a [0,255] clip to [16,235]:
Levels(0, 1, 255, 0, 255)

# the luma is clipped to [16,235] and the conversion [0,255]->[16,235] takes place:
# example: the luma values in [0,16] are all converted to 30
Levels(0, 1, 255, 16, 235)

# gamma-correct image for display in a brighter environment:
# example: luma of 16 stays 16, 59 is converted to 79, etc.
Levels(0, 1.3, 255,0, 255)

# invert the image (make a photo-negative):
# example: luma of 16 is converted to 235
Levels(0, 1, 255, 255, 0)

# does nothing on a [0,255] clip; does nothing on a [16,235]:
Levels(0, 1, 255, 0, 255, coring=false)

# scales a [0,255] clip to a [16,235]:
Levels(0, 1, 255, 16, 235, coring=false)  # this is the same as ColorYUV(levels="PC->TV")

# scales a [16,235] clip to a [0,255]:
Levels(16, 1, 235, 0, 255, coring=false)  # this is the same as ColorYUV(levels="TV->PC")

SourceForge Logo

 


Edit this document | View document history
Document last modified Mon, 31 Jan 2005 15:50:24