PDA

View Full Version : Tweak 'interp' parameter


Gavino
3rd January 2011, 21:43
In the Tweak() filter, the relationship between minSat, maxSat and interp is a bit confusing.

The doc (http://avisynth.org/mediawiki/Tweak) says that interpolation is done in the range [minSat-interp, minSat] and [maxSat, maxSat+interp]. However, the minSat and maxSat arguments are percentages, whereas in the implementation, interp is treated as an absolute saturation value and interpolation is actually done for saturations in the range [minSat'-interp, minSat'] and [maxSat', maxSat'+interp] where minSat' = minSat*1.19 and maxSat'=maxSat*1.19.

So, which is wrong - code or documentation?

Incidentally, the error message for an invalid interp value refers to P instead: "Tweak: P must be greater than or equal to 0 and less than 32."

IanB
4th January 2011, 06:47
Documentation updated.

Error message corrected.

Gavino
4th January 2011, 11:14
Now I'm more confused. :confused:

The updated documentation says interp is "given as a relative value".
I would take this to mean corresponding to saturation on a scale [0, 100], when in fact interp corresponds to saturation on the scale [0, 119] which I would call an absolute value.

IanB
4th January 2011, 21:34
Okay, relative is not the ideal term, I initially typed absolute but I didn't really like it because I was thinking it implied absolute U or V increments, which is still wrong.

Perhaps if we describe the implementation someone can come up with a better word.

For the purposes of the code in Tweak saturation is implemented as :- Sat=Sqrt((u-128)**2 + (v-128)**2)

Saturation adjustment, adjustSat', is linearly adjusted between adjustSat and 1.0 over the 2 ranges [minSat, minSat-Interp] and [maxSat, maxSat+Interp].

For the range minSat-Interp < Sat < maxSat+Interp, both the u and v values have the function applied :- f(x) = clamp((x-128)*adjustSat'+128, 16, 240)

Gavino
4th January 2011, 23:13
I've had a go at rewriting the description of interp in the hope of making it both clear and correct (difficult to do both at the same time :)). Anyone else is of course free to improve it if necessary.

I feel it would have been simpler and more consistent if interp was measured in the same units as minSat and maxSat, but we're stuck with that implementation now.

IanB
5th January 2011, 13:08
I'm not wedded to Interp continuing as it is. We can easily multiply it by 1.19 and call it a bug fix. And I don't really see why we currently need to limit it to 32, it could happily go up to 180.

Well I do know where the 32 came from. The initial implementation had Interp as an integer exponent of 2 between 0 and 5, default 4. Thus the current default of 16 and max of 32.

Thoughts :confused:

Gavino
5th January 2011, 13:31
I'm not wedded to Interp continuing as it is. We can easily multiply it by 1.19 and call it a bug fix. And I don't really see why we currently need to limit it to 32, it could happily go up to 180.
I'd be happy with that, as that's the way I originally thought it worked (before I looked at the code). The effect on backwards compatibility should be minimal.

In the new units, I suppose the extended upper limit would then become 150.