MaskTools/DEdgeMask

From Avisynth wiki
Revision as of 16:01, 9 May 2013 by Admin (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search


DEdgeMask (clip[, int "thY1"[, int "thY2"[, int "thC1"[, int "thC2"[, string "matrix"[, float "divisor"[, bool "setdivisor"[, bool "vmode"]]]]]]]])
DEdgeMask2 (clip source, clip low_thres, clip high_thres[, string "matrix"[, float "divisor"[, bool "setdivisor"[, bool "vmode"]]]])

Plugin: MaskTools

DEdgeMask creates an edge mask of the picture. The edge-finding algorithm uses a 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.

In order to create a binary mask, you just have to set th1=th2.

The choice of the convolution kernel is done with matrix. The matrix must be a 3 by 3 matrix, whose coefficients are integers, separated by a single space. Hence, the strings "-1 -1 -1 -1 8 -1 -1 -1 -1" and "0 -1 0 -1 0 1 0 1 0" will respectively give the kernels "laplace" and "sobel" of the filter EdgeMask.

As coefficients must be integers, divisor is used to refine the result of the convolution. This result will simply be divided by divisor. If divisor isn't defined, it is defaulted to the sum of the positive coefficients of the matrix, thus allowing a classic normalization. It can be either a float or an integer, the later being the faster.

setdivisor is present only for backward compatibility. Do not use it.

Finally vmode allows to output a mask centered to 128 instead of zero.

Defaults are:

  • thY1 = 0, thY2 = 20,
  • thC1 = 0, thC2 = 20,
  • matrix = "-1 -1 -1 -1 8 -1 -1 -1 -1"
  • vmode = false.

DEdgeMask2 basically works like DEdgeMask, except that instead of 2 low / high thresholds, it takes 2 other clips. Each clip contains local thresholds for each pixel.

Let's say you want adaptive thresholds taking local contrast into account. Well, local min & max can be obtained through inpand() and expand(). Difference can be made with YV12LUTxy or YV12Subtract. And voilΰ, you've got a threshold clip containing local contrasts.


Back to MaskTools.

Personal tools