Edge Detection

Find edges of objects in images using Sobel, Prewitt, Roberts, or Canny method

  • Library:
  • Computer Vision Toolbox / Analysis & Enhancement

  • Edge Detection block

Description

The Edge Detection block finds edges of objects in an input image. The Sobel, Prewitt, or Roberts methods find the edges by approximating the gradient magnitude of the image. The block then convolves the input matrix with the Sobel, Prewitt, or Roberts kernel. The Canny method finds edges by looking for the local maxima of the gradient of the input image. The block then calculates the gradient using the derivative of the Gaussian filter.

Ports

Input

expand all

Input image, specified as a matrix of intensity values.

Dependencies

The Canny method does not support 8-bit, 16-bit, or 32-bit signed fixed-point integers or 8-bit, 16-bit, or 32-bit unsigned integers.

Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64 | fixed point

Threshold source, specified as a matrix of intensity values.

Dependencies

The Canny method does not support 8-bit, 16-bit, or 32-bit signed fixed-point integers or 8-bit, 16-bit, or 32-bit unsigned integers.

Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64 | fixed point

Output

expand all

Edge detections, returned as a binary image.

Data Types: Boolean

Matrix of gradient responses to the vertical edges.

Dependencies

  • The Canny method does not support 8-bit, 16-bit, or 32-bit signed fixed-point integers or 8-bit, 16-bit, or 32-bit unsigned integers.

  • To enable this port, set the Method parameter to Sobel or the Prewittmethod.

Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64 | fixed point

Matrix of gradient responses to the horizontal edges.

Dependencies

  • The Canny method does not support 8-bit, 16-bit, or 32-bit signed fixed-point integers or 8-bit, 16-bit, or 32-bit unsigned integers.

  • To enable this port, set the Method parameter to Sobel or Prewitt.

Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64 | fixed point

Matrix of gradient responses to edges at 45 degrees.

Dependencies

  • The Canny method does not support 8-bit, 16-bit, or 32-bit signed or unsigned fixed-point integers.

  • To enable this port, set the Method parameter to Roberts.

Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64 | fixed point

Matrix of gradient responses to edges at 135 degrees.

Dependencies

  • The Canny method does not support fixed point, 8-, 16-, 32-bit signed integers, or 8-, 16-, 32-bit unsigned integers.

  • To enable this port, set the Method parameter to Roberts.

Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64 | fixed point

Parameters

expand all

Specify which algorithm to use to find edges. Select one of the following methods:

  • Sobel

  • Prewitt

  • Roberts

  • Canny

Specify the format of the Edge output.

Algorithm MethodOutput TypeOutput at Edge Port
AllBinary imageBoolean matrix where the zero elements of this correspond to the edge pixels and the zero elements correspond to the background pixels.
Sobel, PrewittGradient componentGradient components that correspond to the horizontal and vertical edge responses at the Gh and Gv ports.
RobertsGradient componentsGradient components that correspond to the 45 and 135 degree edge responses at the G45 and G135 ports.
AllBinary image and gradient componentsBoth the binary image and the gradient components of the image.

Enable the Th port.

Specify the threshold scale factor to automatically calculate threshold value. The block computes the automatic threshold using the mean of the gradient magnitude squared image and multiplies the value of this parameter with the automatic threshold value to determine a new threshold value.

Dependencies

To enable this parameter, clear User-defined threshold.

Specify threshold source. Enter a threshold value that is within the range of your input data. If you choose Input port, use the Th port to specify a threshold value. This value must have the same data type as the input data. Gradient magnitudes above the threshold value correspond to edges.

Dependencies

To enable this parameter, select User-defined threshold.

Select this parameter to reduce the thickness of the edges in your output images. This option requires additional processing time and memory resources.

Note

This block is most efficient in terms of memory usage and processing time when you clear the Edge thinning check box and use the Threshold source parameter to specify a threshold value.

Data Types Tab

For information about the fixed-point block parameters, see Specify Fixed-Point Attributes for Blocks .

Block Characteristics

Data Types

double | fixed point | integer | single

Multidimensional Signals

no

Variable-Size Signals

yes

References

[1] Gonzales, Rafael C. and Richard E. Woods. Digital Image Processing. 2nd ed. Englewood Cliffs, NJ: Prentice Hall, 2002.

[2] Pratt, William K. Digital Image Processing, 2nd ed. NY: John Wiley & Sons, 1991.

Extended Capabilities

C/C++ Code Generation
Generate C and C++ code using Simulink® Coder™.

See Also

Introduced before R2006a