Code: Select all
function FastLineDarken( clip c, int "strength", int "luma_cap", int "threshold", int "thinning") {
str = string(default(strength, 48) /128.)
lum = string(default(luma_cap, 191))
thr = string(default(threshold, 4))
thinning = default(thinning,24)
thn = string(thinning /16.)
exin=c.mt_expand().mt_inpand()
diff = mt_lutxy(c,exin,yexpr="y "+lum+" <y> x y "\
+lum+" < y "+lum+" ? - 0 ? 127 +",uexpr="x",vexpr="x")
linemask = mt_lut(diff.mt_inpand(),"x 127 - "+thn+" * 255 +")\
.mt_convolution("1 1 1","1 1 1",y=3,u=0,v=0)
thick = mt_lutxy(c, exin, yexpr="y "+lum+" <y> x y "\
+lum+" < y "+lum+" ? - 0 ? "+str+" * x +",uexpr="x",vexpr="x")
thin = mt_lutxy(c.mt_expand(),diff,yexpr="x y 127 - "+str+" 1 + * +")
return (thinning == 0) ? thick : mt_merge(thin,thick,linemask,y=3,u=4,v=4)
}