Visible to Intel only — GUID: GUID-CE6FBB08-CE67-4AF2-92C1-823B5A249497
iwiFilterCanny
Syntax
typedef struct _IwiFilterCannyParams
{
IppiDifferentialKernel kernel;
IppiMaskSize kernelSize;
IppNormType norm;
} IwiFilterCannyParams;
static IW_INLINE void iwiFilterCanny_SetDefaultParams(
IwiFilterCannyParams *pParams
)
IW_DECL(IppStatus) iwiFilterCanny(
const IwiImage *pSrcImage,
IwiImage *pDstImage,
Ipp32f treshLow,
Ipp32f treshHigh,
const IwiFilterCannyParams *pAuxParams,
IppiBorderType border,
const Ipp64f *pBorderVal
);
Parameters
pSrcImage |
Pointer to the source image. |
||||||||
pDstImage |
Pointer to the destination image. |
||||||||
treshLow |
Lower threshold for edges detection. |
||||||||
treshHigh |
Upper threshold for edges detection. |
||||||||
pAuxParams |
Pointer to the auxiliary parameters structure. If NULL, default parameters are used. | ||||||||
border |
Extrapolation algorithm for out of image pixels processing. Supported values:
|
||||||||
pBorderVal |
Pointer to an array of values to assign to pixels of the constant border, one element of the array for each channel of the image. This parameter is applicable only to the ippBorderConst border type and can be NULL for other border types. |
Auxiliary Arguments
Argument | Default Value | Description |
---|---|---|
kernel |
ippFilterSobel |
Type of the differential kernel. Supported values: ippFilterSobel, ippFilterScharr. |
kernelSize | ippMskSize3x3 | Size of the filter kernel. Supported values for ippFilterSobel: ippMskSize3x3, ippMskSize5x5; for ippFilterScharr: ippMskSize3x3. |
norm | ippNormL2 | Normalization mode. Supported values: ippNormL1 and ippNormL2. |
Description
This function applies the Canny edge detector [Canny86] to the source image. The detector uses a grayscale image as an input and outputs a black-and-white image, where non-zero pixels mark detected edges. The algorithm consists of three stages described below.
Stage 1: Differentiation
The image data is differentiated in x and y directions. From the computed x and y gradient components, Canny edge detector functions calculate the magnitude and angle of the gradient vector.
Stage 2: Non-maximum Suppression
With the rate of intensity change found at each point in the image, edges must be placed at the points of maximum values of gradient magnitude. It is preferable to suppress non-maximum points that are perpendicular to the edge direction, rather than parallel to the edge direction, as the edge is strong along an extended contour.
The algorithm starts off with sorting the direction of gradient to one of four sectors shown in the figure below.

The algorithm passes a 3x3 neighborhood across the magnitude array. At each point, the center element of the neighborhood is compared with its two neighbors along the line of the gradient given by the sector value. If the central value is not greater than the neighbors, it is suppressed.
Stage 3: Edge Thresholding
The Canny operator uses the so-called “hysteresis” thresholding. Most thresholders use a single threshold limit, which means that if the edge values fluctuate above and below this value, the line appears broken. This phenomenon is commonly referred to as “streaking”. Hysteresis counters streaking by setting an upper and lower edge value limit. Considering a line segment, if a value lies above the upper threshold limit, it is immediately accepted. If the value lies below the low threshold, it is rejected. Points which lie between the two limits are accepted if they are connected to pixels which are also accepted. The likelihood of streaking is small, since the line segment points must fluctuate above the upper limit and below the lower limit for streaking to occur.
J.Canny recommends the ratio of high to low limit be in the range two or three to one, based on predicted signal-to-noise ratios.
This function supports the following features:
Feature | Support |
---|---|
Internal threading | No |
Manual tiling | No |
IwiTile simple tiling | No |
IwiTile pipeline tiling | No |
Return Values
ippStsNoErr |
No errors. |
ippStsMaskSizeErr |
The kernel value is illegal. |
ippStsDataTypeErr |
The dataType value is illegal. |
ippStsNumChannelsErr |
The channels value is illegal. |
ippStsNotEvenStepErr |
The srcStep and/or dstStep value is not divisible by size of elements. |
ippStsBorderErr |
The border value is illegal. |
ippStsNoMemErr |
Failed to allocate memory. |
ippStsSizeErr |
Values of the size fields are illegal. |
ippStsInplaceModeNotSupportedErr |
In-place operation is not supported: pSrc is equal to pDst. |
ippStsNullPtrErr |
At least one of the pointers (except pTile) is NULL. |