Log in

View Full Version : Adjust brightness and contrast: Tweak or Levels ?


numlock
24th August 2004, 05:24
I have a clip in YUY2 colorspace and I need to adjust brightness and contrast

I found 2 filters that can do it

The Levels filter adjusts brightness, contrast, and gamma


Tweak

This function provides the means to adjust the hue, saturation, brightness, and contrast of a video clip.

Which one is better to use ?

tia

stickboy
24th August 2004, 07:19
If you just want to adjust brightness or contrast, Levels will give you more control, since it lets you adjust the black-point, mid-(gray) point, and white-point values individually.

Boulder
24th August 2004, 10:01
Does Tweak affect luma only? If so, it would be the better one IMHO as Levels affects both luma and chroma.

stickboy
25th August 2004, 03:53
I thought that Levels only affects the luma in YUY2 mode anyway?

stickboy
25th August 2004, 06:38
Oops. Levels gamma value affects only the luma, but the white- and black-point values also affect the chroma channels.

trevlac
25th August 2004, 14:15
Originally posted by stickboy
Oops. Levels gamma value affects only the luma, but the white- and black-point values also affect the chroma channels.

Yes ... this is unfortunate. The vdub one has an option to turn this off.

So ... my advice to numlock would be to use Tweak to adjust hue/sat/black/white because you can control them seperately.

Use Levels for gamma.

numlock
25th August 2004, 15:12
Thanks for the input.

Trevlac:

You said to use Tweak to adjust hue/sat/black/white

But what should I use for brightness and contrast ? Tweak also ?

tia

trevlac
25th August 2004, 16:49
Ahh...

brightenss = black
contrast = white

works like this .....

You have a scale of say 0-255 and a given pixel at 23.

Changing brightness moves the pixel up and down the scale. If you wanted the pixel to be black (in YUV) you would move it down to 16. This is normally how you set the 'black level' of a video. Mathematically, this is addition and subtraction.

Changing contrast compresses / stretches the scale up and down while keeping zero fixed. This has the effect of crushing high values at the top to all be 255 if you move it up too much. 2x contrast would make the 23 pixel 46. Mathematically ... it is multiplication. To set the highest white in a video (like a metal reflection or flash), you normally set black then adjust the contrast to set the white to ~235 (for YUV).

I think all of these terms are out there to confuse us ... ;)

stickboy
25th August 2004, 17:46
Originally posted by trevlac
Yes ... this is unfortunate. The vdub one has an option to turn this off.

So ... my advice to numlock would be to use Tweak to adjust hue/sat/black/white because you can control them seperately.

Use Levels for gamma.Well, you know, if you guys really want to leave the chroma untouched:
function LevelsLumaOnly(clip c,
\ int input_low, float gamma, int input_high,
\ int output_low, int output_high)
{
return MergeChroma(c.Levels(input_low, gamma, input_high,
\ output_low, output_high),
\ c)
}

trevlac
25th August 2004, 19:00
Originally posted by stickboy
Well, you know, if you guys really want to leave the chroma untouched:
function LevelsLumaOnly(clip c,
\ int input_low, float gamma, int input_high,
\ int output_low, int output_high)
{
return MergeChroma(c.Levels(input_low, gamma, input_high,
\ output_low, output_high),
\ c)
}

Oh ... that's a good one :) Beauty of Avisynth in the hands of a master. :D

On another note. I made a modified version of tweak. Search for tweak color. It allows you to target specific levels of saturation and pull them down for specific colors. Much harder to do by mucking with the uv planes. (Actually, I'd say near impossible depending on which color you're after.)

What would be really cool is if you could mask off parts of a moving video and go after them. You know, make the main person in a scene really popout. Maybe could be scripted with some of that fancy motion vector stuff.

@numlock

You may also want to get to know how to read a waveform monitor / vector scope display. These are charts that graphically show the various color levels in a video. Then you can actually see what the changes are doing to the pixels. I wrote a piece in the doom9 capture guide that goes over this kind of stuff.

http://www.doom9.org/index.html?/capture/digital_video_color.html
http://www.doom9.org/index.html?/capture/postprocessing_vdub.html

Didée
25th August 2004, 20:52
Ah, changing luma levels without touching chroma.

Note there is also YLevels() (http://forum.doom9.org/showthread.php?s=&threadid=79898&highlight=ylevels) available. Clean, faster than any other method ... and works only on YV12 input :|
It could easily be modified to spit out YUY2 again, but that would kill the speed "advantage". However, I don't know what you all are so doing ... but all of my encodings end up as YV12 anyway ;), and so are my process chains therefore.

If it has to be kept YUY2, use stickboy's function, it's perfect :)

Wilbert
25th August 2004, 23:32
@stickboy,

Can't you add a chroma=true/false setting in Levels (chroma=true is old behavior, default: chroma=false processes only luma)?