MimEdgeDetect()函数

Synopsis

Perform a specific edge detection operation and produce a gradient intensity and/or gradient angle image.

Format

void MimEdgeDetect(SrcImageBufId, DestIntensityImageBufId, DestAngleImageBufId, KernelId, ControlFlag, Threshold)

MIL_ID SrcImageBufId; Source image buffer identifier
MIL_ID DestIntensityImageBufId; Destination gradient intensity image buffer identifier
MIL_ID DestAngleImageBufId; Destination gradient angle image buffer identifier
MIL_ID KernelId; Kernel identifier
long ControlFlag; Flag to control operation
long Threshold; Threshold value for gradient intensity

Description

This function performs an edge detection operation on the specified source image, using the specified kernel. It produces a gradient intensity image and/or a gradient angle image in the specified image buffer(s). If one of the destination images is not required, specify M_NULL as its image buffer identifier.

The SrcImageBufId parameter specifies the identifier of the source of the operation. This parameter must be given an image buffer identifier.

The DestIntensityImageBufId parameter specifies the identifier of the destination of the resulting gradient intensity image. This parameter must be given an image buffer identifier. Saturation is performed on this buffer.

The DestAngleImageBufId parameter specifies the identifier of the destination of the resulting gradient angle image. This parameter must be given an image buffer identifier. The angle is returned from 0° to 360° (counter-clockwise) and mapped in the entire range of the destination buffer. For signed data types, mapping is done in both the positive and negative range of the buffer and represents angle values from -180° to 180°.

The maximum positive value of the angle buffer (255 for an unsigned 8-bit buffer) maps to 360° and is reserved for undefined results produced when a gradient threshold is used.

The KernelId parameter specifies the identifier of the edge detection kernel. This parameter must be set to the predefined 3×3 kernel: M_SOBEL. To disable overscan processing, specify M_SOBEL+M_OVERSCAN_DISABLE). This kernel is as follows:

X gradient: {{-1,0,1},{-2,0,2},{-1,0,1}}
Y gradient: {{1,2,1},{0,0,0},{-1,-2,-1}}

The ControlFlag parameter specifies the flag used to control the operation calculations. These flags include various combinations of fast and full gradient and angle computations.

Full gradient computation uses the equation:

Gradient = srqt(GradientX*GradientX + GradientY*GradientY)

Fast gradient computation uses the equation:

Gradient = ( abs(GradientX) + abs(GradientY) )/2

Full angle computation uses the equation:

Angle = arctan(GradientY/GradientX)

Fast angle approximation introduces a maximum error of +/- 0.4°.

The ControlFlag parameter can be set to one of the following:

ControlFlag Description
M_FAST_EDGE_DETECT Fast computation of the gradient and angle. The gradient is computed as an approximation, using the average of the absolute value of the two directional components (X and Y). Fast angle approximation is used. This is the default flag (M_DEFAULT).
M_REGULAR_EDGE_DETECT Full computation of the gradient and angle. The gradient is computed as the square root of the sum of the square of each directional component (X and Y). This method of calculation is slower but more precise.
M_FAST_ANGLE+M_REGULAR_GRADIENT Full computation of the gradient. Fast angle approximation.
M_REGULAR_ANGLE+M_FAST_GRADIENT Fast computation of the gradient. Full computation of the angle.

The Threshold parameter specifies the threshold value for calculating gradient intensity. For a gradient value lower than the threshold value, the angle is not computed (not considered a significative edge) and the resulting angle pixel is set to the reserved value (the maximum positive value of the buffer). To perform the full operation, set this parameter to zero or M_NULL.

Note

This function can be performed on a floating point buffer. However, the results are not mapped and are returned in the range of 0° to 360° The degree of precision is equal to the precision of the floating point for regular computation and to 0.4° for fast computation. The value for undefined results is the maximum positive value of the floating point buffer.