DIPlib Documentation - ©1995-2013 Quantitative Imaging Group, Delft University of Technology.

# Canny

Edge detector

## SYNOPSIS

`#include "dip_detection.h"`

dip_Error dip_Canny ( in, out, sigma, upper, lower )

## DATA TYPES

Input is integer or float; output is binary.

## FUNCTION

The Canny edge detector finds the ridges in the gradient magnitude, which correspond to the edges in the image. The gradient magnitude (see `GradientMagnitude`) is computed using Gaussian derivatives, with a sigma of `sigma` in both dimensions. The found ridges are pruned to remove the less salient edges. A threshold `t1` is computed so that the `1-upper` fraction of pixels with the highest gradient magnitude are kept. A second threshold, `t2 = t1*lower`, is selected that determines the minimal gradient magnitude expected of an edge. All edge pixels that exceed `t2`, and are in the same connected region as at least one pixel that exceeds `t1`, are selected as the output of this function (see `HysteresisThreshold`).

## ARGUMENTS

Data type | Name | Description
`dip_Image` | `in` | Input
`dip_Image` | `out` | Output
`dip_float` | `sigma` | Sigma parameter for Gaussian derivatives
`dip_float` | `lower` | Lower threshold, as a fraction of upper threshold
`dip_float` | `upper` | Percentile used to compute upper threshold

## LIMITATIONS

This function only works on 2D images.