MysteryX
26th June 2021, 18:51
Creating this thread for reference if others are looking to use MaskTools2 in VapourSynth.
The library itself has not been ported, but most functions can easily be replaced.
mt_lutspa: VapourSynth-Draw (https://github.com/kewenyu/VapourSynth-Draw)
mt_motion: MotionMask (https://github.com/dubhater/vapoursynth-motionmask)
mt_lut and mt_lutxy: Expr (http://www.vapoursynth.com/doc/functions/expr.html)
Note: Expr does not support Pixel Addressing (http://avisynth.nl/index.php/Expr#Pixel_addressing) (neither does mt_lut) but they may add it in the future (https://github.com/vapoursynth/vapoursynth/issues/703)
mt_binarize: Binarize (http://www.vapoursynth.com/doc/functions/binarize.html)
mt_merge: MaskedMerge (http://www.vapoursynth.com/doc/functions/maskedmerge.html#std.MaskedMerge)
mt_inpand and mt_expand: Minimum/Maximum (http://www.vapoursynth.com/doc/functions/minimum_maximum.html)
Maximum() however gives square output
mt_expand(mode= mt_circle(zero=true, radius=1))
# can be replaced with
std.Maximum(coordinates=[0, 1, 0, 1, 1, 0, 1, 0])
mt_expand(mode= mt_circle(zero=true, radius=8)
# best replacement I found, let me now if you find better
C = C.std.Maximum()
C = C.std.Maximum(coordinates=[0, 1, 0, 1, 1, 0, 1, 0])
C = C.std.Maximum()
C = C.std.Maximum(coordinates=[0, 1, 0, 1, 1, 0, 1, 0])
C = C.std.Maximum()
C = C.std.Maximum(coordinates=[0, 1, 0, 1, 1, 0, 1, 0])
Other useful functions to work with masks
Overlay (https://github.com/HomeOfVapourSynthEvolution/havsfunc/blob/019ad633afa2982dfee8959435b2a0deb862c9f7/havsfunc.py#L5427)
Blur: Convolution (http://www.vapoursynth.com/doc/functions/convolution.html)
Blur(1.0) can be replaced with std.Convolution(matrix=[1, 2, 1, 2, 4, 2, 1, 2, 1]) or std.Convolution(matrix=[10, 20, 10, 20, 40, 20, 10, 20, 10]) gives the exact same result. You can fine-tune the weighting to your needs. This gives similar to Blur(0.6): std.Convolution(matrix=[0, 1, 0, 1, 3, 1, 0, 1, 0]).
You can add any further info on the topic to this thread.
The library itself has not been ported, but most functions can easily be replaced.
mt_lutspa: VapourSynth-Draw (https://github.com/kewenyu/VapourSynth-Draw)
mt_motion: MotionMask (https://github.com/dubhater/vapoursynth-motionmask)
mt_lut and mt_lutxy: Expr (http://www.vapoursynth.com/doc/functions/expr.html)
Note: Expr does not support Pixel Addressing (http://avisynth.nl/index.php/Expr#Pixel_addressing) (neither does mt_lut) but they may add it in the future (https://github.com/vapoursynth/vapoursynth/issues/703)
mt_binarize: Binarize (http://www.vapoursynth.com/doc/functions/binarize.html)
mt_merge: MaskedMerge (http://www.vapoursynth.com/doc/functions/maskedmerge.html#std.MaskedMerge)
mt_inpand and mt_expand: Minimum/Maximum (http://www.vapoursynth.com/doc/functions/minimum_maximum.html)
Maximum() however gives square output
mt_expand(mode= mt_circle(zero=true, radius=1))
# can be replaced with
std.Maximum(coordinates=[0, 1, 0, 1, 1, 0, 1, 0])
mt_expand(mode= mt_circle(zero=true, radius=8)
# best replacement I found, let me now if you find better
C = C.std.Maximum()
C = C.std.Maximum(coordinates=[0, 1, 0, 1, 1, 0, 1, 0])
C = C.std.Maximum()
C = C.std.Maximum(coordinates=[0, 1, 0, 1, 1, 0, 1, 0])
C = C.std.Maximum()
C = C.std.Maximum(coordinates=[0, 1, 0, 1, 1, 0, 1, 0])
Other useful functions to work with masks
Overlay (https://github.com/HomeOfVapourSynthEvolution/havsfunc/blob/019ad633afa2982dfee8959435b2a0deb862c9f7/havsfunc.py#L5427)
Blur: Convolution (http://www.vapoursynth.com/doc/functions/convolution.html)
Blur(1.0) can be replaced with std.Convolution(matrix=[1, 2, 1, 2, 4, 2, 1, 2, 1]) or std.Convolution(matrix=[10, 20, 10, 20, 40, 20, 10, 20, 10]) gives the exact same result. You can fine-tune the weighting to your needs. This gives similar to Blur(0.6): std.Convolution(matrix=[0, 1, 0, 1, 3, 1, 0, 1, 0]).
You can add any further info on the topic to this thread.