From Avisynth wiki
Jump to: navigation, search
Author tritical
Version v1.0
Category Edge Detection
License GPLv2


[edit] Description

tcanny contains a Canny edge detection filter and distance transform filter.

[edit] Requirements

[edit] Syntax and Parameters

[edit] tcanny

Builds an edge map using Canny edge detection.

tcanny(clip, float "sigma", float "t_h", float "t_l", int "nms", int "mode", int "plane", float "gmmax")

clip   =
Input clip; only YUY2 and YV12 are supported.

float  sigma = 1.5
Standard deviation of Gaussian blur. 0 means no blurring before edge detection.

float  t_h = 8.0
High gradient magnitude threshold for hysteresis.

float  t_l = 1.0
Low gradient magnitude threshold for hysteresis.

int  nms = 3
Byte mask choosing non-maxima suppression method(s).
If (nms&1) - if pixel is maxima along nearest integer direction then keep.
If (nms&3) - if pixel is maxima along linearly interpolated direction then keep.

int  mode = 0
Sets the output format:
  • 0 : thresholded edge map (255 for edge, 0 for non-edge)
  • 1 : gradient magnitude map. Scaled to 0-255 range based on gmmax.
pixel_val = min(grad_mag*255/gmmax,255)
  • 2 : edge pixel only gradient direction map (non-edge pixels set to 0)
  • 3 : gradient direction map
            Gradient direction maps discretize [0-180) degree range into 256 bins.

                 0 = [000.000-000.351}
                 1 = [000.351-001.054)
               255 = [179.648-180.000)

                        135   90  45
                           \  |  /
                       180 --   -- 0
                            / |  \
                          45  90  135

                * This is the gradient direction, so the line direction 
                  is orthogonal to it (90 degree rotation). It only goes 
                  through 180 because for this case:

                     180+n = n, 0 <= n < 180

int  plane = 1
Byte mask indicating which planes to process. If a plane isn't processed then it is copied through as is.
if (plane&1) - process Y
if (plane&2) - process U
if (plane&4) - process V

float  gmmax = 50.0
Used for scaling gradient magnitude into [0,255] for mode=1.
gmmax is internally set to 1.0 if you set it to < 1.0.

[edit] tdtrans

Performs a distance transformation on an edge map. This filter assumes the input image is 0 for non-edge pixels, and > 0 for edge pixels.
The distance transform sets each pixel equal to the distance from it to the nearest edge pixel.

tdtrans (clip, int "mode", int "plane")

clip   =
Input clip; only YUY2 and YV12 are supported.

int  mode = 1
Sets distance type.
  • 0 - city block
  • 1 - euclidean
* For the euclidean case the distance is rounded to the nearest integer.
* For both cases distances greater than 255 are set to 255.

int  plane = 1
Byte mask indicating which planes to process. Same as in tcanny.

[edit] Examples

tcanny with default settings:

TCannyMod(sigma=1.5, t_h=8.0, t_l=1.0, nms=3, mode=0, plane=1, gmmax=50.0)

tdtrans with default settings:

tdtrans(mode=1, plane=1)

[edit] Changelog

Version      Date            Changes
v1.0 06/03/2009 - Initial release

[edit] Archived Downloads

Version Download Mirror

[edit] External Links

Back to External Filters

Personal tools