# visionhdl.EdgeDetector

Find edges of objects

## Description

The `visionhdl.EdgeDetector`

System object™ finds the edges in a grayscale pixel stream using the Sobel, Prewitt, or
Roberts method. The object convolves the input pixels with derivative approximation
matrices to find the gradient of pixel magnitude along two orthogonal directions. It
then compares the sum of the squares of the gradients to a configurable threshold to
determine if the gradients represent an edge. The Sobel and Prewitt methods calculate
the gradient in horizontal and vertical directions. The Roberts method calculates the
gradients at 45 and 135 degrees.

The object returns a binary image as a stream of pixel values. A pixel value of 1 indicates that the pixel is an edge. You can optionally enable output of the gradient values in the two orthogonal directions at each pixel.

To find the edges of objects:

Create the

`visionhdl.EdgeDetector`

object and set its properties.Call the object with arguments, as if it were a function.

To learn more about how System objects work, see What Are System Objects?

## Creation

### Description

returns a System object that detects edges using the Sobel method.`detectEdges`

= visionhdl.EdgeDetector

returns an edge detector System object with properties specified using one or more name-value pairs.
Enclose each property name in single quotes.`detectEdges`

= visionhdl.EdgeDetector(`Name`

,`Value`

)

## Properties

## Usage

### Syntax

### Description

`[`

detects edges in the neighborhood of `edge`

,`ctrlout`

] = detectEdges(`pixelin`

,`ctrlin`

)`pixelin`

by computing
the gradient in two orthogonal directions. The `edge`

output
argument is a binary value indicating whether the sum of the squares of the
gradients for the input pixel is above the threshold indicating an edge.

`[`

detects edges in the neighborhood of `G1`

,`G2`

,`ctrlout`

] = detectEdges(`pixelin`

,`ctrlin`

)`pixelIn`

by computing
the gradient in two orthogonal directions. Use this syntax when you set the
`GradientComponentOutputPorts`

property to
`true`

. The `G1`

and
`G2`

output arguments are the gradients calculated in the
two orthogonal directions. When you set the `Method`

property
to '`Sobel'`

or `'Prewitt'`

, the first
argument is the vertical gradient, and the second argument is the horizontal
gradient. When you set the `Method`

property to
`'Roberts'`

, the first argument is the 45-degree gradient,
and the second argument is the 135-degree gradient.

`[`

detects edges in the neighborhood of `edge`

,`ctrlout`

] = detectEdges(`pixelin`

,`ctrlin`

,`thresh`

)`pixelin`

by computing
the gradient in two orthogonal directions. Use this syntax when you set the
`ThresholdSource`

property to
`'InputPort'`

. The `edge`

output
argument is a binary value indicating whether the sum of the squares of the
gradients is above the threshold, `thresh`

, squared.

You can use any combination of the optional argument syntaxes.

This object uses a streaming pixel interface with a structure
for frame control signals. This interface enables the object to operate independently of image
size and format and to connect with other Vision HDL Toolbox™ objects. The object accepts and returns a scalar pixel value and control signals
as a structure containing five signals. The control signals indicate the validity of each pixel
and its location in the frame. To convert a pixel matrix into a pixel stream and control
signals, use the `visionhdl.FrameToPixels`

object. For a
description of the interface, see Streaming Pixel Interface.

### Input Arguments

### Output Arguments

## Object Functions

To use an object function, specify the
System object as the first input argument. For
example, to release system resources of a System object named `obj`

, use
this syntax:

release(obj)

## Examples

## Algorithms

This object implements the algorithms described on the Edge Detector block reference page.

## Extended Capabilities

## Version History

**Introduced in R2015a**

## See Also

Edge Detector | `edge`

(Image Processing Toolbox) | `visionhdl.FrameToPixels`