Log in

View Full Version : MaskTools-value that differ the most from avg


Terka
6th January 2010, 16:13
have 3 clips, want to have value that differ the most from avg.

so clips are:
b,n,f
avg=(b+n+f)/3
max=max(b,n,f)
min=min(b,n,f)
maxdelta=max-avg
mindelta =avg-min
if(maxdelta>mindelta;max;min)

could someone help me to create this using MaskTools?

Didée
6th January 2010, 16:50
Fiddly, but absolutely doable. Though, there's a little problem ... say,

max=120
avg=100
min=80

- which value to return? And, if e.g. max=121, then why return max and not min? max and min are very different, but their deviation is almost the same ...

And just to be clear: I assume you mean per-pixel, i.e. construct a new frame from the most-different pixels? (Because per-frame would be even more fiddly to do...)

Didée
6th January 2010, 17:25
Assuming per-pixel, here is a literal implementation of the request:
(completely untested, just written down)


# so clips are:
# b,n,f

# avg=(b+n+f)/3
avg = average( b,1./3, n,1./3, f,1./3 )

# max=max(b,n,f)
max = mt_logic(b,n,"max",U=3,V=3).mt_logic(f,"max",U=3,V=3)

# min=min(b,n,f)
min = mt_logic(b,n,"min",U=3,V=3).mt_logic(f,"min",U=3,V=3)

# maxdelta=max-avg
maxdelta = mt_lutxy(max,avg,"x y -",U=3,V=3)

# mindelta =avg-min
mindelta = mt_lutxy(avg,min,"x y -",U=3,V=3)

# if(maxdelta>mindelta;max;min)
use_max = mt_lutxy(maxdelta,mindelta,"x y > 255 0 ?",U=3,V=3)
min.mt_merge(max,use_max,U=3,V=3)

Terka
6th January 2010, 19:45
yes, you are right as usual. i think it can be handeld later by changing the logic like
if(maxdelta>mindelta+threshold;max;min)
per pixel.
do it for 2 reasons:
1.learning masktools
2.want to try to make 'a fake detail'.
filters usually average, this is a bit opposite.
Thank you,
Terka
PS: i want to add the result to lets say 'n' so i think i have to use some function which is converging to the max 225.
because otherwise i could get overexposed places.
Manao, thank you.

Manao
7th January 2010, 09:27
mt_lutxyz might be faster