Sagekilla: I am not much concerned about the speed of processing - the most important quality.
I do not know why, can severely distort the color jpg .. But the moon surrounded by little red. Inversion of the mask is well shown. Look at 60783903.jpg.
This code:
mt_lutxy(c, mask, "x 128 - abs "+string(threshold)+" < y 0 ?")
greatly reduces the sensitivity and do not protect against color transitions.
function LineMask( clip c, clip mask, int "threshold")
{
threshold = Default(threshold, 30)
linemask = mt_lutxy(c, mask, "x 128 - abs "+string(threshold)+" < y 0 ?")
return(linemask)
}
Function EM_FuPP(clip i, int "e_th1", int "e_th2", int "e_th3")
{
e_th1 = Default(e_th1, 131)
e_th2 = Default(e_th2, 135)
e_th3 = Default(e_th3, 62)
diff = mt_makediff(i.blur(1.58).blur(1.58),i)
a=diff.mt_binarize(threshold = e_th1).mt_inflate().mt_inflate()
b=diff.mt_binarize(threshold = e_th2).mt_inflate().mt_inflate()
c=i.mt_binarize(e_th3, upper=true)
return mt_logic(b,mt_logic(a,c,"and"),"or")
}
Function DR_Radius(clip i, int dr_rad, int count)
{
return count > dr_rad ? i : DR_Radius(i.mt_expand(), dr_rad, count+1)
}
Function DeHaloH(clip input, int "DR_Radius", int "DR_Str", bool "Maska")
{
Maska = Default(Maska, false)
EM=input.EM_FuPP()
# EM=LineMask(input, EM)
RM=DR_Radius(EM,DR_Radius,0)
DeRinging = input.Deen("a2d", 2, DR_Str , 0, 0, 0, 0, 0)
DeRinging = Maska ? DeRinging.Invert() : DeRinging
return mt_Merge(input, DeRinging, RM)
}
Call:
DeHaloH(2, 15, Maska=true)
|