The OpenVX Specification  a73e458
Canny Edge Detector

## Detailed Description

Provides a Canny edge detector kernel.

This function implements an edge detection algorithm similar to that described in [2]. The main components of the algorithm are:

• Gradient magnitude and orientation computation using a noise resistant operator (Sobel).
• Non-maximum suppression of the gradient magnitude, using the gradient orientation information.
• Tracing edges in the modified gradient image using hysteresis thresholding to produce a binary result.

The details of each of these steps are described below.

• Gradient Computation: Conceptually, the input image is convolved with vertical and horizontal Sobel kernels of the size indicated by the gradient_size parameter. The Sobel kernels used for the gradient computation shall be as shown below. The two resulting directional gradient images ( $$dx$$ and $$dy$$) are then used to compute a gradient magnitude image and a gradient orientation image. The norm used to compute the gradient magnitude is indicated by the norm_type parameter, so the magnitude may be $$|dx| + |dy|$$ for VX_NORM_L1 or $$\sqrt{dx^{2} + dy^{2}}$$ for VX_NORM_L2. The gradient orientation image is quantized into 4 values: 0, 45, 90, and 135 degrees.

$\mathbf{sobel}_{x}= \begin{vmatrix} -1 & 0 & 1\\ -2 & 0 & 2\\ -1 & 0 & 1 \end{vmatrix}$

$\mathbf{sobel}_{y}=transpose({sobel}_{x})= \begin{vmatrix} -1 & -2 & -1\\ 0 & 0 & 0\\ 1 & 2 & 1 \end{vmatrix}$

$\mathbf{sobel}_{x}= \begin{vmatrix} -1 & -2 & 0 & 2 & 1\\ -4 & -8 & 0 & 8 & 4\\ -6 & -12 & 0 & 12 & 6\\ -4 & -8 & 0 & 8 & 4\\ -1 & -2 & 0 & 2 & 1\\ \end{vmatrix}$

$\mathbf{sobel}_{y}=transpose({sobel}_{x})$

$\mathbf{sobel}_{x}= \begin{vmatrix} -1 & -4 & -5 & 0 & 5 & 4 & 1\\ -6 & -24 & -30 & 0 & 30 & 24 & 6\\ -15 & -60 & -75 & 0 & 75 & 60 & 15\\ -20 & -80 & -100 & 0 & 100 & 80 & 20\\ -15 & -60 & -75 & 0 & 75 & 60 & 15\\ -6 & -24 & -30 & 0 & 30 & 24 & 6\\ -1 & -4 & -5 & 0 & 5 & 4 & 1\\ \end{vmatrix}$

$\mathbf{sobel}_{y}=transpose({sobel}_{x})$

• Non-Maximum Suppression: This is then applied such that a pixel is retained as a potential edge pixel if and only if its magnitude is greater than or equal to the pixels in the direction perpendicular to its edge orientation. For example, if the pixel's orientation is 0 degrees, it is only retained if its gradient magnitude is larger than that of the pixels at 90 and 270 degrees to it. If a pixel is suppressed via this condition, it must not appear as an edge pixel in the final output, i.e., its value must be 0 in the final output.
• Edge Tracing: The final edge pixels in the output are identified via a double thresholded hysteresis procedure. All retained pixels with magnitude above the high threshold are marked as known edge pixels (valued 255) in the final output image. All pixels with magnitudes less than or equal to the low threshold must not be marked as edge pixels in the final output. For the pixels in between the thresholds, edges are traced and marked as edges (255) in the output. This can be done by starting at the known edge pixels and moving in all eight directions recursively until the gradient magnitude is less than or equal to the low threshold.
• Caveats: The intermediate results described above are conceptual only; so for example, the implementation may not actually construct the gradient images and non-maximum-suppressed images. Only the final binary (0 or 255 valued) output image must be computed so that it matches the result of a final image constructed as described above [R00032].

## Modules

Normalization type constants.

## Functions

vx_node VX_API_CALL vxCannyEdgeDetectorNode (vx_graph graph, vx_image input, vx_threshold hyst, vx_int32 gradient_size, vx_enum norm_type, vx_image output)
[Graph] Creates a Canny Edge Detection Node. More...

## ◆ vxCannyEdgeDetectorNode()

 vx_node VX_API_CALL vxCannyEdgeDetectorNode ( vx_graph graph, vx_image input, vx_threshold hyst, vx_int32 gradient_size, vx_enum norm_type, vx_image output )

[Graph] Creates a Canny Edge Detection Node.

Parameters
 [in] graph The reference to the graph [R00338]. [in] input The input VX_DF_IMAGE_U8 image [R00339]. [in] hyst The double threshold for hysteresis [R00340]. The threshold data_type shall be either VX_TYPE_UINT8 or VX_TYPE_INT16 [R00341]. The VX_THRESHOLD_TRUE_VALUE and VX_THRESHOLD_FALSE_VALUE of vx_threshold are ignored. [in] gradient_size The size of the Sobel filter window, must support at least 3, 5, and 7 [R00342]. [in] norm_type A flag indicating the norm used to compute the gradient, VX_NORM_L1 or VX_NORM_L2 [R00343]. [out] output The output image in VX_DF_IMAGE_U8 format with values either 0 or 255 [R00344].
Returns
vx_node.
Return values
 vx_node A node reference. Any possible errors preventing a successful creation should be checked using vxGetStatus