Note: This page has been translated by MathWorks. Click here to see

To view all translated materials including this page, select Country from the country navigator on the bottom of this page.

To view all translated materials including this page, select Country from the country navigator on the bottom of this page.

Find edges in intensity image

`BW = edge(I)`

`BW = edge(I,method)`

`BW = edge(I,method,threshold)`

`BW = edge(I,method,threshold,direction)`

`BW = edge(___,'nothinning')`

`BW = edge(I,method,threshold,sigma)`

`BW = edge(I,method,threshold,h)`

```
[BW,threshOut]
= edge(___)
```

```
[BW,threshOut,Gv,Gh]
= edge(___)
```

specifies the orientation of edges to detect. The Sobel and Prewitt methods can
detect edges in the vertical direction, horizontal direction, or both. The
Roberts method can detect edges at angles of 45° from horizontal, 135° from
horizontal, or both. This syntax is valid only when `BW`

= edge(`I`

,`method`

,`threshold`

,`direction`

)`method`

is `'Sobel'`

, `'Prewitt'`

, or
`'Roberts'`

.

`[`

also returns the directional gradient magnitudes. For the Sobel and Prewitt
methods, `BW`

,`threshOut`

,`Gv`

,`Gh`

]
= edge(___)`Gv`

and `Gh`

correspond to the
vertical and horizontal gradients. For the Roberts methods,
`Gv`

and `Gh`

correspond to the
gradient at angles of 45° and 135° from horizontal, respectively. This syntax is
valid only when `method`

is `'Sobel'`

,
`'Prewitt'`

, or `'Roberts'`

.

For the gradient-magnitude edge detection methods (Sobel, Prewitt, Roberts),

`edge`

uses`threshold`

to threshold the calculated gradient magnitude.For the zero-crossing methods, including Laplacian of Gaussian,

`edge`

uses`threshold`

as a threshold for the zero-crossings. In other words, a large jump across zero is an edge, while a small jump is not.The Canny method applies two thresholds to the gradient: a high threshold for low edge sensitivity and a low threshold for high edge sensitivity.

`edge`

starts with the low sensitivity result and then grows it to include connected edge pixels from the high sensitivity result. This helps fill in gaps in the detected edges.In all cases,

`edge`

chooses the default threshold heuristically, depending on the input data. The best way to vary the threshold is to run`edge`

once, capturing the calculated threshold as the second output argument. Then, starting from the value calculated by`edge`

, adjust the threshold higher to detect fewer edge pixels, or lower to detect more edge pixels.

[1] Canny, John, "A Computational Approach to Edge Detection,"
*IEEE Transactions on Pattern Analysis and Machine
Intelligence,* Vol. PAMI-8, No. 6, 1986, pp. 679-698.

[2] Lim, Jae S., *Two-Dimensional
Signal and Image Processing*, Englewood Cliffs, NJ, Prentice
Hall, 1990, pp. 478-488.

[3] Parker, James R., *Algorithms
for Image Processing and Computer Vision,* New York, John
Wiley & Sons, Inc., 1997, pp. 23-29.