Documentation Center

  • Trial Software
  • Product Updates

vision.EdgeDetector System object

Package: vision

Find object edge

Description

The EdgeDetector object finds edges of objects in images. For Sobel, Prewitt and Roberts algorithms, the object finds edges in an input image by approximating the gradient magnitude of the image. The object obtains the gradient as a result of convolving the image with the Sobel, Prewitt or Roberts kernel. For Canny algorithm, the object finds edges by looking for the local maxima of the gradient of the input image. The calculation derives the gradient using a Gaussian filter. This algorithm is more robust to noise and more likely to detect true weak edges.

Construction

H = vision.EdgeDetector returns an edge detection System object, H, that finds edges in an input image using Sobel, Prewitt, Roberts, or Canny algorithm.

H = vision.EdgeDetector(Name,Value) returns an edge detection object, H, with each specified property set to the specified value. You can specify additional name-value pair arguments in any order as (Name1, Value1,...,NameN,ValueN).

Code Generation Support
Supports MATLAB® Function block: Yes
System Objects in MATLAB Code Generation.
Code Generation Support, Usage Notes, and Limitations.

Properties

Method

Edge detection algorithm

Specify the edge detection algorithm as one of Sobel | Prewitt | Roberts | Canny. The default is Sobel.

BinaryImageOutputPort

Output the binary image

Set this property to true to output the binary image after edge detection. When you set this property to true, the object will output a logical matrix. The nonzero elements of this matrix correspond to the edge pixels and the zero elements correspond to the background pixels. This property applies when you set the Method property to Sobel, Prewitt or Roberts.

The default is true.

GradientComponentOutputPorts

Output the gradient components

Set this property to true to output the gradient components after edge detection. When you set this property to true, and the Method property to Sobel or Prewitt, this System object outputs the gradient components that correspond to the horizontal and vertical edge responses. When you set the Method property to Roberts, the System object outputs the gradient components that correspond to the 45 and 135 degree edge responses. Both BinaryImageOutputPort and GradientComponentOutputPorts properties cannot be false at the same time.

The default is false.

ThresholdSource

Source of threshold value

Specify how to determine threshold as one of Auto | Property | Input port. The default is Auto. This property applies when you set the Method property to Canny. This property also applies when you set the Method property to Sobel, Prewitt or Roberts and the BinaryImageOutputPort property to true.

Threshold

Threshold value

Specify the threshold value as a scalar of a MATLAB built-in numeric data type. When you set the you set the Method property to Sobel, Prewitt or Roberts, you must a value within the range of the input data. When you set the Method property to Canny, specify the threshold as a two-element vector of low and high values that define the weak and strong edges. This property is accessible when the ThresholdSource property is Property. This property is tunable.

The default is[0.25 0.6] when you set the Method property to Canny. Otherwise, The default is20.

ThresholdScaleFactor

Multiplier to adjust value of automatic threshold

Specify multiplier that is used to adjust calculation of automatic threshold as a scalar MATLAB built-in numeric data type. This property applies when you set the Method property to Sobel, Prewitt or Roberts and the ThresholdSource property to Auto. This property is tunable.

The default is 4.

EdgeThinning

Enable performing edge thinning

Indicate whether to perform edge thinning. Choosing to perform edge thinning requires additional processing time and resources. This property applies when you set the Method property to Sobel, Prewitt or Roberts and the BinaryImageOutputPort property to true.

The default is false.

NonEdgePixelsPercentage

Approximate percentage of weak and nonedge pixels

Specify the approximate percentage of weak edge and nonedge image pixels as a scalar between 0 and 100. This property applies when you set the Method property to Canny and the ThresholdSource to Auto. This property is tunable.

The default is 70.

GaussianFilterStandardDeviation

Standard deviation of Gaussian

filter Specify the standard deviation of the Gaussian filter whose derivative is convolved with the input image. You can set this property to any positive scalar. This property applies when you set the Method property to Canny.

The default is 1.

 Fixed-Point Properties

Methods

cloneCreate edge detector object with same property values
getNumInputsNumber of expected inputs to step method
getNumOutputsNumber of outputs from step method
isLockedLocked status for input attributes and nontunable properties
release Allow property value and input characteristics changes
stepFind edges in input image

Examples

expand all

Find Edges In An Image

Create edge detector, color space converter, and image type converter objects.

     hedge = vision.EdgeDetector;
     hcsc = vision.ColorSpaceConverter('Conversion', 'RGB to intensity');
     hidtypeconv = vision.ImageDataTypeConverter('OutputDataType','single');

Read in the original image and convert color and data type.

     img = step(hcsc, imread('peppers.png'));
     img1 = step(hidtypeconv, img);

Find edges.

     edges = step(hedge, img1);

Display original and image with edges.

     subplot(1,2,1);
     imshow(imread('peppers.png'));
     subplot(1,2,2);
     imshow(edges);

Algorithms

This object implements the algorithm, inputs, and outputs described on the Edge Detection block reference page. The object properties correspond to the block parameters.

See Also

Was this topic helpful?