Log in

View Full Version : Levels before Tweak?


Cyberia
11th January 2005, 21:38
If I intend to use both Levels and Tweak in a script, is there a specific order I should use them in?

I'm thinking that Levels should always come first.

Also, if Levels is used correctly, then a brightness/contrast adjustment in tweak is always unnecessary also right? wrong?

Didée
12th January 2005, 10:43
Hmh, I don't think there's a particular order to use tweak & levels.

For levels() alone, I'd say that:

- if you're going to smooth the source, then do levels() first.
- in case of sharpening the source, apply levels() afterwards.

(For the reason that levels() will cause "stairsteps" in the histogram.)


>> if Levels is used correctly, then [...] tweak is always unnecessary also right? wrong?

Both right and wrong. You just can't make a general statement like that. (Personally, I never use tweak's contrast&brightness functions, except for quick visualizations.)

One thing to remember is that levels() processes *both* luma and chroma: Gamma is applied to luma only, but the low & high control points are also applied to the chroma planes, with a gamma value of 1. That's why often a tweak(sat=[>1.0]) is applied after a levels() command ... which is a somewhat quirky operation sequence.

To avoid level's chroma processing, one could either use "mergechroma(levels(...)), or use the faster Ylevels() (http://forum.doom9.org/showthread.php?s=&threadid=79898) function.

Cyberia
12th January 2005, 20:10
Well, reversing the order does not produce the same output. It's a little different.
LoadPlugin("DGDecode.DLL")
video=mpeg2source("LASER.d2v", idct=3, moderate_h=20, moderate_v=40, iPP=True, cpu2="XXXXXX")

video2=video.Tweak(1, 1.5, 0, 1, False)
video2=video2.Levels(5, 1, 240, 0, 255, False)

video=video.Levels(5, 1, 240, 0, 255, False)
video=video.Tweak(1, 1.5, 0, 1, False)

subtract(video, video2).Levels(127, 1, 129, 0, 255)
produces different output than
LoadPlugin("DGDecode.DLL")
video=mpeg2source("LASER.d2v", idct=3, moderate_h=20, moderate_v=40, iPP=True, cpu2="XXXXXX")

video2=video.Tweak(1, 1.5, 0, 1, False)
video2=video2.Levels(5, 1, 240, 0, 255, False)

video=video.Tweak(1, 1.5, 0, 1, False)
video=video.Levels(5, 1, 240, 0, 255, False)

subtract(video, video2).Levels(127, 1, 129, 0, 255)
I'll have to think this over. Since they aren't communicable (ie: clip*tweak*levels =! clip*levels*tweak) order may be relevant.

Didée
13th January 2005, 00:16
Of course that's not the same. Like in maths: F(G(x)) is in most cases not the same as F(G(x)). But which produces the "correct" results? Well, they both do, if the desired result is arbitrary (here: "the effect that you want to achieve").