MaskTools2/Mt merge
From Avisynth wiki
Description
It's the backbone of the framework. It merges two clips according to the mask. The bigger the mask value, the more the second clip will be taken into account.
For 8 bits the actual formula is:
y = ((256 - m) * x1 + m * x2 + 128) / 256
Since v2.2.7: keep original pixels from clip1/2 when mask is exactly 0 or 255:
y = (m == 0) ? x1 : (m == 255) ? x2 : ((256 - m) * x1 + m * x2 + 128) / 256
Syntax and Parameters
- mt_merge (clip, clip, clip, bool "luma", int "Y", int "U", int "V", string "chroma", int "offX", int "offY", int "w", int "h")
or since v2.2.15
- mt_merge (clip, clip, clip, bool "luma", float "Y", float "U", float "V", string "chroma", int "offX", int "offY", int "w", int "h", float "A", string "cplace")
- clip =
- Input clip one.
- clip =
- clip =
- Input clip two.
- clip =
- clip =
- Mask input clip.
- clip =
- bool luma = false
- luma is a special mode, where only the luma plane of the mask is used to process all three channels.
- bool luma = false
- int Y = 3
- int U = 2
- int V = 2
- int A = 2
- These 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. (-255..0 range can of course differ when non-8 bit video formats are used)
- 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.
- U, V and A are defaulted to 2 (that way, the resulting clip contains the chroma (alpha) of clip1, and looks right).
- These 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 & 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
- string cplace = "mpeg2"
- "mpeg1" : Simple block averaging (e.g. average 2x2 pixels to a single YV12 chroma mask)
- "mpeg2" : default
- Since v2.2.15.
- Parameter defines chroma placement hint for 4:2:0 and 4:2:2 formats.
- string cplace = "mpeg2"
Examples
mt_merge with default settings: (TO DO)
clip1 = original clip2 = processed mask = mask
mt_merge(clip1, clip2, mask, Y=3, U=2, V=2, chroma="", w=-1, h=-1)
Back to MaskTools2 ←