# edge3

Find edges in 3-D intensity volume

## Syntax

``BW = edge3(V,'approxcanny',thresh)``
``BW = edge3(V,'approxcanny',thresh,sigma)``
``BW = edge3(V,'Sobel',thresh)``
``BW = edge3(V,'Sobel',thresh,'nothinning')``

## Description

````BW = edge3(V,'approxcanny',thresh)` returns the edges found in the intensity or a binary volume `V` using the approximate Canny method. The approximate Canny method finds edges by looking for local maxima of the gradient of `V`. `edge3` calculates the gradient using the derivative of a Gaussian smoothed volume.For the approximate Canny method, `thresh` is a two-element vector in which the first element is the low threshold, and the second element is the high threshold, `[lowthresh highthresh]`. If you specify a scalar for `thresh`, `edge3` uses this value for the high threshold and `0.4*thresh` for the low threshold.The approximate Canny method uses two thresholds to detect strong and weak edges, and includes the weak edges in the output only if they are connected to strong edges. This method is more likely than the Sobel method to detect true weak edges.```

example

````BW = edge3(V,'approxcanny',thresh,sigma)` returns the edges found in the intensity or binary volume `V`, where `sigma` is a scalar that specifies the standard deviation of the Gaussian smoothing filter. `sigma` can also be a 1-by-3 vector, `[SigmaX,SigmaY,SigmaZ]`, specifying different standard deviations in each direction. For anisotropic volumes that have different scales in each direction, use multiple sigma values. By default, `sigma` is `sqrt(2)` and is isotropic. `edge3` chooses the size of the filter automatically, based on `sigma`.```

example

````BW = edge3(V,'Sobel',thresh)` accepts an intensity or a binary volume `V` and returns a binary volume `BW`, that is the same size as `V`, with 1s where the function finds edges in `V` and 0s elsewhere.The Sobel method finds edges using the Sobel approximation to the derivative. It returns edges at those points where the gradient of `V` is maximum.`thresh` is a scalar that specifies the sensitivity threshold for the Sobel method. `edge3` ignores all edges that are not stronger than `thresh`.```
````BW = edge3(V,'Sobel',thresh,'nothinning')` speeds up the operation of the algorithm by skipping the additional edge-thinning stage. By default, or when `'thinning'` is specified, the algorithm applies edge thinning.```

## Examples

collapse all

Load volumetric data and remove any singleton dimensions.

```load mri V = squeeze(D); ```

View the volume using `volshow`.

```volshow(V); ``` Detect edges in the volume using `edge3` with the approximate Canny method.

```BW = edge3(V,'approxcanny',0.6); ```

View the detected edges using `volshow`.

```volshow(BW); ``` ## Input Arguments

collapse all

Input volume, specified as a nonsparse 3-D numeric array.

Data Types: `single` | `double` | `int8` | `int16` | `int32` | `int64` | `uint8` | `uint16` | `uint32` | `uint64` | `logical`

Sensitivity threshold, specified as a scalar or, for approximate Canny, a 1-by-2 numeric vector of the form `[lowthresh highthresh]`. If you specify a scalar, `edge3` uses this value for the high threshold and `0.4*thresh` for the low threshold.

Data Types: `single` | `double` | `int8` | `int16` | `int32` | `int64` | `uint8` | `uint16` | `uint32` | `uint64` | `logical`

Standard deviation of the Gaussian filter, specified as a scalar or a 1-by-3 numeric vector of the form ```[SigmaX SigmaY SigmaZ]```.

Data Types: `single` | `double` | `int8` | `int16` | `int32` | `int64` | `uint8` | `uint16` | `uint32` | `uint64` | `logical`

## Output Arguments

collapse all

Binary volume containing 1s indicating edges and 0s elsewhere, returned as a 3-D numeric array, the same size as `V`.