MaskTools2/Mt edge
From Avisynth wiki
(Difference between revisions)
m (1 revision) |
m (→Syntax and Parameters) |
||
(One intermediate revision by one user not shown) | |||
Line 1: | Line 1: | ||
{{FilterCat|External_filters|Other_filters|Support_filters}} | {{FilterCat|External_filters|Other_filters|Support_filters}} | ||
− | + | ----------------------------------------------- | |
+ | '''Back to [[MaskTools2#Filters|MaskTools2]] ←''' | ||
+ | ----------------------------------------------- | ||
+ | <br> | ||
+ | == 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 <tt>thY1</tt> and <tt>thY2</tt> (luma) and <tt>thC1</tt> and <tt>thC2</tt> (chroma). | ||
− | + | :The thresholding happens like this (r is the result of the convolution): | |
− | + | ::* r <= th1 gives 0. | |
− | + | ::* th1 < r <= th2 gives r. | |
− | * r <= th1 gives 0. | + | ::* th2 < r gives 255. |
− | * th1 < r <= th2 gives r. | + | <br> |
− | * th2 < r gives 255. | + | == Syntax and Parameters == |
− | + | :{{Template:FuncDef|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")}} | |
− | < | + | <br> |
− | "sobel" uses the kernel "0 -1 0 -1 0 1 0 1 0" | + | ::{{Par2| |clip| }} |
− | {| class="wikitable" style="text-align: center; width: | + | :::Input clip |
+ | <br> | ||
+ | ::{{Par2|mode|string|"sobel"}} | ||
+ | :::{{Template:FuncDef3|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 ). | ||
+ | <br> | ||
+ | :::*"sobel" uses the kernel "0 -1 0 -1 0 1 0 1 0" | ||
+ | ::::{| class="wikitable" style="text-align: center; width: 75px; height: 75px;" | ||
|- | |- | ||
| 0 | | 0 | ||
Line 26: | Line 41: | ||
| 1 | | 1 | ||
| 0 | | 0 | ||
− | |} | + | |} |
− | "roberts": "0 0 0 0 2 -1 0 -1 0" | + | :::*"roberts": "0 0 0 0 2 -1 0 -1 0" |
− | {| class="wikitable" style="text-align: center; width: | + | ::::{| class="wikitable" style="text-align: center; width: 75px; height: 75px;" |
|- | |- | ||
| 0 | | 0 | ||
Line 44: | Line 59: | ||
|} | |} | ||
− | + | :::*"laplace": "1 1 1 1 -8 1 1 1 1" | |
− | {| class="wikitable" style="text-align: center; width: | + | ::::{| class="wikitable" style="text-align: center; width: 75px; height: 75px;" |
|- | |- | ||
| 1 | | 1 | ||
Line 60: | Line 75: | ||
|} | |} | ||
+ | :::*"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: | ||
+ | ::::<pre>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")</pre> | ||
− | + | :::* "prewitt" is a more robust kernel and is equivalent to: | |
− | * < | + | ::::<pre>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")</pre> |
− | + | <br> | |
− | + | ::{{Par2|thY1|int|10}} | |
− | + | ::{{Par2|thY2|int|10}} | |
− | + | ::{{Par2|thC1|int|10}} | |
+ | ::{{Par2|thC2|int|10}} | ||
+ | :::{{Template:FuncDef3|thY1}} and {{Template:FuncDef3|thY2}} are the low and high threshold for luma. {{Template:FuncDef3|thC1}} and {{Template:FuncDef3|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. | ||
− | ---- | + | :::Range: 0 to 255 |
− | Back to [[MaskTools2]] | + | <br> |
+ | ::{{Par2|Y|int|3}} | ||
+ | ::{{Par2|U|int|1}} | ||
+ | ::{{Par2|V|int|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. | ||
+ | <br> | ||
+ | ::{{Par2|chroma|string|""}} | ||
+ | :::When defined, the value contained in this string will overwrite the {{Template:FuncDef3|U}} & {{Template:FuncDef3|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. | ||
+ | <br> | ||
+ | ::{{Par2|offX|int|0}} | ||
+ | ::{{Par2|offY|int|0}} | ||
+ | :::{{Template:FuncDef3|offx}} and {{Template:FuncDef3|offy}} are the top left coordinates of the box where the actual processing shall occur. Everything outside that box will be garbage. | ||
+ | <br> | ||
+ | ::{{Par2|w|int|-1}} | ||
+ | ::{{Par2|h|int|-1}} | ||
+ | :::{{Template:FuncDef3|w}} and {{Template:FuncDef3|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. | ||
+ | <br> | ||
+ | <br> | ||
+ | ----------------------------------------------- | ||
+ | '''Back to [[MaskTools2#Filters|MaskTools2]] ←''' | ||
+ | ----------------------------------------------- |
Latest revision as of 18:49, 4 August 2014
Back to MaskTools2 ←
[edit] 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.
[edit] 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 ←