MaskTools2/mt logic
From Avisynth wiki
Back to MaskTools2 ←
[edit] Description
mt_logic combines masks using logic operators. In other words, this filter produces a new mask which is the result of a binary operation between two masks. The operation is chosen with the parameter mode
.
[edit] Syntax and Parameters
 mt_logic (clip, clip, string "mode", float "th1", float "th2", float "Y", float "U", float "V", string "chroma", int "offX", int "offY", int "w", int "h", int "sse2", bool "sse3", bool "ssse3", bool "sse4", bool "avx", bool "avx2", float "A", string "alpha")
 clip =
 Input clip one.
 clip =
 clip =
 Input clip two.
 clip =
 string mode = "and"
 Available modes:

"and"
: Works only with binary masks (only pixels at 0 or 255). The output mask is the intersection of the two masks. It means that if both corresponding pixels are 255, the resulting pixel will be 255, else 0. 
"or"
: Works only with binary masks. The output mask is the union of the two masks. It means that if one of the corresponding pixels are 255, the resulting pixel will be 255, else 0. 
"xor"
: Works only with binary masks. The output mask is the difference between the two masks. It means that if one ( exclusively ) of the corresponding pixels are 255, the resulting pixel will be 255, else 0. 
"andn"
: Works only with binary masks. The output mask is the subtraction of the second mask from the first one. It means that if the pixel of the first mask is 255 and the second is 0, it will return 255, else 0. 
"min"
: Returns for each pixel the minimum value between the two pixels of the input masks. It amounts to mode="and", but for non binary masks. 
"max"
: Returns for each pixel the maximum value between the two pixels of the input masks. It amounts to mode="or", but for non binary masks.

 Note: If a logical operator is used with a non binary mask, the results are unpredictable.
 Available modes:
 string mode = "and"
 int Y = 3
 int U = 1
 int V = 1
 These three values describe the actual processing mode that is to be used on each plane / channel. Here is how the modes are coded :
 x = 255...0 : all the pixels of the plane will be set to x.
 x = 1 : the plane will not be processed. That means the content of the plane after the filter is pure garbage.
 x = 2 : the plane of the first input clip will be copied.
 x = 3 : the plane will be processed with the processing the filter is designed to do.
 x = 4 : the plane of the second input clip will be copied.
 These three values describe the actual processing mode that is to be used on each plane / channel. Here is how the modes are coded :
 int Y = 3
 string chroma = ""
 When defined, the value contained in this string will overwrite the U and V processing modes.
 This is a nice addition proposed by mg262 that makes the filter more user friendly. Allowed values for chroma are:
 "process" : set u = v = 3.
 "copy" or "copy first" : set u = v = 2.
 "copy second" : set u = v = 4.
 "xxx", where xxx is a number : set u = v = xxx.
 string chroma = ""
 int offX = 0
 int offY = 0
 offX and offY are the top left coordinates of the box where the actual processing shall occur. Everything outside that box will be garbage.
 int offX = 0
 int w = 1
 int h = 1
 w and h are the width and height of the processed box. 1 means that the box extends to the lower right corner of the video. That also means that default settings are meant to process the whole picture.
 int w = 1
[edit] Examples
mt_logic with default settings:
mask1 = blah mask2 = blah
mt_logic(mask1, mask2, mode="and", Y=3, U=1, V=1, chroma="", w=1, h=1)
Back to MaskTools2 ←