Log in

View Full Version : Change max white color


anton_foy
11th September 2022, 19:56
Hi, is there a quick and simple way to change max white color to black?
Even would like to expand spatially so the neighbouring pixels of the max white area also gets black.
Right now I do it like this:

function b_edge(clip c, int "thresh", int "br")
{
bemask = c.mt_binarize(threshold=thresh).mt_expand().removegrain(20,-1)
blc = c.levels(0,1,255*256,0,(br*256))
mt_merge(c,blc,bemask,y=3,u=1,v=1)
return last
}

But it is quite slow.

Dogway
11th September 2022, 22:01
You can use this:

br=0
ex_binarize(200,hi=br,lo=-1,smooth=false,UV=1)

Spotted some issues with function, so here's the updated version for the time being: https://pastebin.com/v0gwdgDg

anton_foy
12th September 2022, 08:18
You can use this:

br=0
ex_binarize(200,hi=br,lo=-1,smooth=false,UV=1)

Spotted some issues with function, so here's the updated version for the time being: https://pastebin.com/v0gwdgDg

Wow thanks Dogway I will try it out today.

Dogway
12th September 2022, 08:28
Had some time so I finished (https://github.com/Dogway/Avisynth-Scripts/blob/e4527c08b107efd4598a425b2421ac34cc8345ca/ExTools.avsi#L769)it, and optimized further (code was convoluted).
Might not be the very exact thing but you can give it a try, now also working with smooth=true for a clean transition.