MaskTools2/Mt edge
(Removed incorrect table. (The last coefficient wasn't 8, it was the normalization factor.)) |
m (1 revision) |
Revision as of 16:02, 9 May 2013
mt_edge (clip[, int "thY1"[, int "thY2"[, int "thC1"[, int "thC2"[, string "mode"]]]]])
Plugin: MaskTools2
This filter creates an edge mask of the picture. 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 that (r is the result of the convolution):
- r <= th1 gives 0.
- th1 < r <= th2 gives r.
- th2 < r gives 255.
mode choses the 3x3 convolution kernel used for the mask computing. There are three predefined kernel, "sobel", "roberts" and "laplace", and you can enter also a 3x3 custom kernel. "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 |
and "laplace": "1 1 1 1 -8 1 1 1 1".
1 | 1 | 1 |
1 | -8 | 1 |
1 | 1 | 1 |
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 ).
Three new kernels have been introduced lately : "prewitt", "cartoon" and "min/max". "prewitt" is a more robust kernel, while "cartoon" behaves like "roberts", but takes only negative edges into account. Finally, "min/max" computes the local contrast ( local max - local min ).
More precisely, "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")
and "prewitt" 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")
Default Values:
- thY1 = 10
- thY2 = 20
- thC1 = 10
- thC2 = 20
- mode = "sobel"
Back to MaskTools2.