View Full Version : Thresholding difference clips with Mt_Lut


*.mp4 guy
18th February 2009, 20:06
I would like to threshold a difference clip created by mt_makediff, so that if it is within a threshold value of 127 (or whatever the center value of mt_makediff is) it is made equal to 127.

The combination of reverse polich notation and bolean vairables is making this difficult for me to figure out.

[edit] this is what i came up with:
Mt_lut( " X 127 "+string(thresh)+" + > 127 x ? 127 "+string(thresh)+" - < 127 x ? ", u=2, v=2)

but it doesn't work, as it processes the clip even when thresh=0

[edit2] Mt_lut( " X 127 - abs "+string(thresh)+" < 127 x ? ", u=2, v=2) apears to be correct, but it doesn't do quite what I expected, so I'm still open to advice.

Didée
18th February 2009, 20:44
mt_makediff centers around '128'.

Small trick: just one condition.
"x 128 - abs "+string(thresh)+" <= 128 x ?"

Straightforward using two conditions, you had wrong ordering of the ternary operator.
"x 128 "+string(thresh)+" - > 128 x 128 "+string(thresh)+" + < 128 x ? ?" edit2: The code ^above^ is nonsense.

or combine both conditions with OR:

"x 128 "+string(thresh)+" - > x 128 "+string(thresh)+" + < | 128 x ?" edit2: The code ^above^ is nonsense.


Edit: grrr, missed your edit. :)

Your expression in [edit2] seems correct. What's the goal again? Keep "small" differences & discard "big" differences? Or vice versa?

*.mp4 guy
18th February 2009, 22:15
The goal is to discard small changes and leave big ones, I'm experimenting with a hacked together pseudo sub-band-transform.

Didée
18th February 2009, 23:33
OMG. The ones with 2 ternaries are checking whether a value is smaller than (128+t) OR bigger than (128-t). Well, that's TRUE, for all numbers that do exist. :D

Oh, mewants to vanish into thin air ...
# # "Avisynth style":

mt_lut("x 128 - abs "+string(thresh)+" <= 128 x ?") # abs(x-128) <= th ? 128 : orig

mt_lut("x 128 "+string(thresh)+" - < x x 128 "+string(thresh)+" + > x 128 ? ?") # (x < 128-th) ? x
# \ : (x > 128+th) ? x
# \ : 128

mt_lut("x 128 "+string(thresh)+" - < x 128 "+string(thresh)+" + > | x 128 ?") # (x < 128-th) || (x > 128+th) ? x : 128

[*vanishes into thin air*]