View Single Post
Old 17th January 2020, 23:29   #56  |  Link
zorr
Registered User
 
Join Date: Mar 2018
Posts: 447
Quote:
EDIT: I did consider trying out Expr() but shied off as I've never used it before. [I presume it will take Masktools expressions without change].
Yes Expr is a lot like MaskTools.

I tried to do a pretty much direct and simplified conversion of my VapourSynth version. It's using your GreyRamp() and limited 256x256 resolution and only processing the luma channel... yet it seems to run out of memory or stack space. I can get it to process 20-30 mask values but anything more and it craps out in multitude of ways, yet the memory usage is actually very low.

The version below is processing a modest number of mask values, you can try more by changing the mask_value of the applyFunc call or the recursion test value on the last line of applyFunc. Some of these issues may be because I only have an ancient x86 version of Avisynth installed. The applyFunc should be run inside ScriptClip in order to use animated masks but that made it fail as well.

Code:
src = AVISource("source.avi")
src = ConvertToYV16(src)
src = Crop(src, 0,0,256,256)

mask = GreyRamp()
mask = ConvertToY8(mask)

final = BlankClip(src)
result = applyFunc(mask, src, final, 128)

return result

Function applyFunc(mask, src, final, int mask_value) {
	m = mask.mt_lut("x "+String(mask_value)+" = 255 0 ?")
	gradient_clip = blurx(src, mask_value/255.0)
	final = mt_lutxyz(final, gradient_clip, m, "z 255 = y x ?")
	return mask_value < 140 ? applyFunc(mask, src, final, mask_value+1) : final	
}

Function blurx(clip, float ratio) {
	return FastBlur(clip, ratio*5.0)
}
zorr is offline   Reply With Quote