MaskTools2/Mt edge
From Avisynth wiki
Back to MaskTools2 ←
Description
- This filter creates an edge mask. The edge-finding algorithm uses a (3x3) convolution kernel, and the result of the convolution is then thresholded with thY1 and thY2 (luma) and thC1 and thC2 (chroma).
- The thresholding happens like this (r is the result of the convolution):
- r <= th1 gives 0.
- th1 < r <= th2 gives r.
- th2 < r gives 255.
Syntax and Parameters
- mt_edge (clip, string "mode", int "thY1", int "thY2", int "thC1", int "thC2", int "Y", int "U", int "V", string "chroma", int "offX", int "offY" int "w", int "h")
- clip =
- Input clip
- clip =
- string mode = "sobel"
- mode chooses the 3x3 convolution kernel used for the mask computing.
- There are 7 predefined kernel, "sobel", "roberts", "laplace", "cartoon", "min/max", "hprewitt", and "prewitt".
- Additionally, you can also enter also a custom 3x3 kernel. The normalization factor of the kernel is automatically
- computed and ceiled to the closest power of 2, to allow faster processing. You can specify your own normalization
- factor by adding it to the list of coefficients ( "1 1 1 1 -8 1 1 1 1 8" for example ).
- string mode = "sobel"
- "sobel" uses the kernel "0 -1 0 -1 0 1 0 1 0"
0 -1 0 -1 0 1 0 1 0
- "roberts": "0 0 0 0 2 -1 0 -1 0"
0 0 0 0 2 -1 0 -1 0
- "laplace": "1 1 1 1 -8 1 1 1 1"
1 1 1 1 -8 1 1 1 1
- "cartoon" behaves like "roberts", but takes only negative edges into account.
- "min/max" computes the local contrast (local max - local min).
- "hprewitt" is equivalent to:
mt_logic(mt_edge("1 2 1 0 0 0 -1 -2 -1 1"), mt_edge("1 0 -1 2 0 -2 1 0 -1 1"), mode="max")
- "prewitt" is a more robust kernel and is equivalent to:
mt_logic(mt_logic(mt_edge("1 1 0 1 0 -1 0 -1 -1 1"),mt_edge("1 1 1 0 0 0 -1 -1 -1 1"),mode="max"),mt_logic(mt_edge("1 0 -1 1 0 -1 1 0 -1 1"),mt_edge("0 -1 -1 1 0 -1 1 1 0 1"),mode="max"),mode="max")
- int thY1 = 10
- int thY2 = 10
- int thC1 = 10
- int thC2 = 10
- thY1 and thY2 are the low and high threshold for luma. thC1 and thC2 are the same but for chroma.
- If the pixel value is less than thX1, the pixel is set to 0, if it's greater than thX2 then it's set to 255, anything in between is left untouched.
- int thY1 = 10
- Range: 0 to 255
- 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.
- 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 & 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.
- "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.
- This also means that default settings are meant to process the whole picture.
- int w = -1
Back to MaskTools2 ←