| MIL 10 Reference
| Customize Help
| Save Settings

MimConvolve



See also
Availability
Not available in MIL-Lite
Available in MIL

Available on Windows
Available on Linux

Partially supported on:
Partially supported on Matrox GPU processing driver

Fully supported on:
Fully supported on Host system
Fully supported on Matrox CronosPlus
Fully supported on Matrox GigE Vision driver
Fully supported on Matrox IEEE 1394 IIDC driver
Fully supported on Matrox Iris GT
Fully supported on Matrox Morphis
Fully supported on Matrox Morphis QxT
Fully supported on Matrox Orion HD
Fully supported on Matrox Radient eCL
Fully supported on Matrox Radient eV-CXP
Fully supported on Matrox Solios eA/XA
Fully supported on Matrox Solios ecl/xcl/ev-cl
Fully supported on Matrox USB3 Vision driver (requires Update 19)
Fully supported on Matrox Vio

For any information regarding a MIL system added during a MIL Update, see the MIL system’s release note

Available on Non-Matrox computer
Available on Matrox 4Sight-X
Available on Matrox 4Sight GP
Available on Matrox Supersight
function map Function map
Examples
Synopsis
Perform a general convolution operation.
Syntax
void MimConvolve(
MIL_ID SrcImageBufId, //in
MIL_ID DstImageBufId, //in
MIL_ID KernelBufId //in
)
Description

This function performs a general convolution operation on the source buffer using the specified filter, storing results in the specified destination buffer. This function supports two types of filters: Finite Impulse Response (FIR) filters and Infinite Impulse Response (IIR) filters. FIR filters operate on a finite neighborhood, while IIR filters take in account all values in an image. You can specify either a predefined or a custom FIR or IIR filter.

This function provides a number of predefined FIR. For predefined FIR filters, the overscan is set to transparent overscan pixel values, saturation is enabled for results, and the kernel's default center pixel is set as the top-left pixel of the central elements in a neighborhood. When using predefined FIR filters, you cannot change operation control settings except for the overscan.

This function provides two types of predefined IIR filters. Predefined IIR filters, M_SHEN_FILTER() and M_DERICHE_FILTER(), use a recursive implementation, and the overscan pixel values are ignored. The normalization factor is automatically set so that it is possible to use the full data range of the destination buffer without overflows, and the result is given in the number of bits of the destination buffer. When using predefined IIR filters, you cannot change operation control settings except for the smoothness value. To use an IIR filter in kernel mode, you must use a custom IIR filter.

This function also accepts a custom FIR or IIR filter with which you can customize operation control settings. To define a custom filter, you must allocate a kernel buffer using MbufAlloc1d() or MbufAlloc2d(). Note that the kernel buffer size can be constrained by the available resources.

To define a custom FIR filter, you must load the kernel buffer with values, using MbufPut(). To define a custom IIR filter, use MbufControlNeighborhood() with M_FILTER_TYPE, M_FILTER_OPERATION, and M_FILTER_MODE; the kernel values are automatically calculated based on these settings.

When using custom FIR or IIR filters, you can change default operation control settings using MbufControlNeighborhood().

For predefined and custom FIR filters, when using 32-bit integer buffers and saturation is disabled, the accumulator buffer is a 32-bit integer buffer (MIL_INT); whereas, when saturation is enabled, the accumulator buffer is a 64-bit floating-point internal buffer (double). For IIR filters, when using 32-bit floating-point source or destination images, operations are performed using floating-point precision; whereas, for other types of images, operations are performed using fixed-point precision.

For custom FIR filters, this function will internally separate a large kernel into two 1-dimensional kernels, if possible, to increase the speed of the convolution operation. For more information on separating kernels, see the Finite Impulse Response (FIR) filters subsection of the Custom spatial filters section of Chapter 4: Advanced image processing.

Custom FIR filters containing a unique value (such as uniform kernels or average kernels) are dealt with by a specifically targeted algorithmic optimization.

If the source and destination are multi-band buffers, the same filter is applied to every band of the source buffer.

Note that this function reference has not been updated for a MIL system added during a MIL update. Refer to the MIL system's release note to see which MIL system’s documentation you should use in its place and any possible differences.
Parameters
This function is not supported on the selected boards.
This function reference has not been updated for the selected MIL system. To show the content of this page, choose a second MIL system; refer to the MIL system's release note to see which MIL system’s documentation to choose and any possible differences.
Parameters
SrcImageBufId

Specifies the identifier of the data source of the operation. This parameter must be given an image buffer identifier.

This image buffer must not have a region of interest (ROI) associated with it. Using an image buffer with an ROI will cause an error.

Note that for an FIR filter or custom IIR filter which uses a kernel mode implementation, the size of the image buffer must be greater or equal to the size of the kernel.

[Matrox GPU processing driver]

The source image buffer must be either unsigned M_MONO8, M_MONO16 or M_BGR32 packed.

DstImageBufId

Specifies the identifier of the destination of the results. This parameter must be given an image buffer identifier.

This image buffer must not have a region of interest (ROI) associated with it. Using an image buffer with an ROI will cause an error.

Note that for an FIR filter or custom IIR filter which uses a kernel mode implementation, the size of the image buffer must be greater or equal to the size of the kernel.

[Matrox GPU processing driver]

The source image buffer must be either unsigned M_MONO8, M_MONO16 or M_BGR32 packed.

KernelBufId

Specifies the filter to use. Set this parameter to a predefined filter or the identifier of the kernel buffer which defines the custom filter.

To specify a custom FIR or IIR filter, set this parameter to the following:

function map For specifying a custom FIR or IIR filter
CollapseValue Description
Collapse Kernel Buffer ID

Specifies the identifier of the kernel buffer, allocated using MbufAlloc...() with M_KERNEL. For more details, refer to the Custom spatial filters section of Chapter 4: Advanced image processing.

(summarize)

To specify a predefined FIR filter, set this parameter to one of the following:

function map For specifying a predefined FIR filter
CollapseValue Description
Collapse M_EDGE_DETECT_PREWITT_FAST +

Computes the gradient of the image using the following operation, which is based on a Prewitt filter.

Collapse M_EDGE_DETECT_SOBEL_FAST +

Computes the gradient of the image using the following operation, which is based on a Sobel filter.

Collapse M_HORIZONTAL_EDGE_PREWITT +

Computes the absolute value of the horizontal derivative of the image using the horizontal Prewitt edge detection filter.

Collapse M_HORIZONTAL_EDGE_SOBEL +

Computes the absolute value of the horizontal derivative of the image using the horizontal Sobel edge detection filter.

Collapse M_LAPLACIAN_4 +

Computes the Laplacian values of the image using the following 4-connected Laplacian edge detection filter.

Collapse M_LAPLACIAN_8 +

Computes the Laplacian values of the image using the following 8-connected Laplacian edge detection filter.

Collapse M_SHARPEN_4 +

Performs a sharpening operation on the image using the following 4-connected Laplacian filter combined with the original image.

Note that this operation results in a sharpening effect that is not as strong as the one achieved with M_SHARPEN_8.

(summarize)
Collapse M_SHARPEN_8 +

Performs a sharpening operation on the image using the following 8-connected Laplacian filter combined with the original image.

Note that this operation results in a stronger sharpening effect than M_SHARPEN_4.

(summarize)
Collapse M_SMOOTH +

Performs a smoothing operation on the image using the following smoothing filter.

Collapse M_VERTICAL_EDGE_PREWITT +

Computes the absolute value of the vertical derivative of the image using the vertical Prewitt edge detection filter.

Collapse M_VERTICAL_EDGE_SOBEL +

Computes the absolute value of the vertical derivative of the image using the vertical Sobel edge detection filter.

Combination constants for the values listed in For specifying a predefined FIR filter.

You can add one of the following values to the above-mentioned values to specify how to determine the value of a destination pixel when its associated point falls outside the source buffer.

function map For specifying how to determine the value of a destination pixel when its associated point falls outside the source buffer
CollapseCombination value Description
Collapse M_OVERSCAN_DISABLE

Disables overscanning temporarily. You should disable overscanning to accelerate the convolution for applications in which the overscan data is not important in the resulting buffer.

(summarize)
Collapse M_OVERSCAN_FAST

Specifies that MIL will automatically select the overscan that optimizes speed, according to the specified operation and the target system. The overscan could be hardware-specific thereby having a different behavior than the other supported overscan modes.

Note that when using M_OVERSCAN_FAST, the destination pixels in the overscan area are undefined. The pixels can therefore contain different values from one function call to the next, even if the function's parameter values are the same.

(summarize)

To specify a predefined IIR filter, set this parameter to one of the following:

function map For specifying a predefined IIR filter
CollapseValue Description
MIL system-specific
tooltip (†)
Collapse

Specifies a Canny-Deriche Infinite Support Exponential filter. This is an exponential weighting function, of the general form:

For the Canny-Deriche filter, the neighborhoods' influence decreases much slower as the distance from the central pixel increases, compared to the Shen-Castan filter (see M_SHEN_FILTER() macro).

Possible values for the OperationType and SmoothFactor parameters of M_DERICHE_FILTER() macro are described below.

(summarize)
a b c e f g h i j k l m n o p q r s
Parameters

This parameter specifies the type of operation to perform. You can set this parameter to one of the following:

a b c e f g h i j k l m n o p q r s
M_DEFAULT

Same as M_SMOOTH.

a b c e f g h i j k l m n o p q r s
M_EDGE_DETECT

Computes the gradient of the image using the Canny-Deriche filter.

a b c e f g h i j k l m n o p q r s
M_EDGE_DETECT_SQR

Computes the square of the gradient of the image using the Canny-Deriche filter.

a b c e f g h i j k l m n o p q r s
M_FIRST_DERIVATIVE_X

Computes the first derivative of the image, with respect to X, using the Canny-Deriche filter.

a b c e f g h i j k l m n o p q r s
M_FIRST_DERIVATIVE_Y

Computes the first derivative of the image, with respect to Y, using the Canny-Deriche filter.

a b c e f g h i j k l m n o p q r s
M_HORIZ_EDGE

Computes the absolute value of the horizontal derivative of the image using the Canny-Deriche filter.

a b c e f g h i j k l m n o p q r s
M_LAPLACIAN_EDGE

Computes the Laplacian values of the image using the Canny-Deriche filter.

a b c e f g h i j k l m n o p q r s
M_SECOND_DERIVATIVE_X

Computes the second derivative of the image, with respect to X, using the Canny-Deriche filter.

a b c e f g h i j k l m n o p q r s
M_SECOND_DERIVATIVE_XY

Computes the second derivative of the image, with respect to X and Y, using the Canny-Deriche filter.

a b c e f g h i j k l m n o p q r s
M_SECOND_DERIVATIVE_Y

Computes the second derivative of the image, with respect to Y, using the Canny-Deriche filter.

a b c e f g h i j k l m n o p q r s
M_SHARPEN

Performs a sharpening operation on the image using the Canny-Deriche filter.

a b c e f g h i j k l m n o p q r s
M_SMOOTH

Performs a smoothing operation on the image using the Canny-Deriche filter.

a b c e f g h i j k l m n o p q r s
M_VERT_EDGE

Computes the absolute value of the vertical derivative of the image using the Canny-Deriche filter.

a b c e f g h i j k l m n o p q r s

This parameter specifies the degree of smoothness (strength of the denoising) applied by the convolution operation. You can set this parameter to one of the following:

a b c e f g h i j k l m n o p q r s
M_DEFAULT

The default value is 50.0.

a b c e f g h i j k l m n o p q r s
0.0 <= Value <= 100.0

Specifies the smoothness value.

A value of 100.0 results in a strong noise reduction effect, while a value of 0.0 has almost no noise reduction effect.

a b c e f g h i j k l m n o p q r s
Collapse

Specifies a Shen-Castan Infinite Support Exponential filter. This is an exponential weighting function, of the general form:

For the Shen-Castan filter, the neighborhoods' influence decreases much faster as the distance from the central pixel increases, compared to the Canny-Deriche filter (see M_DERICHE_FILTER() macro).

Possible values for the OperationType and SmoothFactor parameters of M_SHEN_FILTER() macro are described below.

(summarize)
a b c e f g h i j k l m n o p q r s
Parameters

This parameter specifies the type of operation to perform. You can set this parameter to one of the following:

a b c e f g h i j k l m n o p q r s
M_DEFAULT

Same as M_SMOOTH.

a b c e f g h i j k l m n o p q r s
M_EDGE_DETECT

Computes the gradient of the image using the Shen-Castan filter.

a b c e f g h i j k l m n o p q r s
M_EDGE_DETECT_SQR

Computes the square of the gradient of the image using the Shen-Castan filter.

a b c e f g h i j k l m n o p q r s
M_FIRST_DERIVATIVE_X

Computes the first derivative of the image, with respect to X, using the Shen-Castan filter.

a b c e f g h i j k l m n o p q r s
M_FIRST_DERIVATIVE_Y

Computes the first derivative of the image, with respect to Y, using the Shen-Castan filter.

a b c e f g h i j k l m n o p q r s
M_HORIZ_EDGE

Computes the absolute value of the horizontal derivative of the image using the Shen-Castan filter.

a b c e f g h i j k l m n o p q r s
M_LAPLACIAN_EDGE

Computes the Laplacian values of the image using the Shen-Castan filter.

a b c e f g h i j k l m n o p q r s
M_SECOND_DERIVATIVE_X

Computes the second derivative of the image, with respect to X, using the Shen-Castan filter.

a b c e f g h i j k l m n o p q r s
M_SECOND_DERIVATIVE_XY

Computes the second derivative of the image, with respect to X and Y, using the Shen-Castan filter.

a b c e f g h i j k l m n o p q r s
M_SECOND_DERIVATIVE_Y

Computes the second derivative of the image, with respect to Y, using the Shen-Castan filter.

a b c e f g h i j k l m n o p q r s
M_SHARPEN

Performs a sharpening operation on the image using the Shen-Castan filter.

a b c e f g h i j k l m n o p q r s
M_SMOOTH

Performs a smoothing operation on the image using the Shen-Castan filter.

a b c e f g h i j k l m n o p q r s
M_VERT_EDGE

Computes the absolute value of the vertical derivative of the image using the Shen-Castan filter.

a b c e f g h i j k l m n o p q r s

This parameter specifies the degree of smoothness (strength of the denoising) applied by the convolution operation. You can set this parameter to one of the following:

a b c e f g h i j k l m n o p q r s
M_DEFAULT

The default value is 50.0.

a b c e f g h i j k l m n o p q r s
0.0 <= Value <= 100.0

Specifies the smoothness value.

A value of 100.0 results in a strong noise reduction effect, while a value of 0.0 has almost no noise reduction effect.

a b c e f g h i j k l m n o p q r s
Compilation information
Header Include mil.h.
Library Use mil.lib; milim.lib.
DLL Requires mil.dll; milim.dll.
PROC NONE PROC NONE EDGE DETECT PREWITT FAST EDGE DETECT SOBEL FAST HORIZONTAL EDGE PREWITT HORIZONTAL EDGE SOBEL LAPLACIAN 4 LAPLACIAN 8 SHARPEN 4 SHARPEN 8 SMOOTH VERTICAL EDGE PREWITT VERTICAL EDGE SOBEL OVERSCAN DISABLE OVERSCAN FAST DEFAULT EDGE DETECT EDGE DETECT SQR FIRST DERIVATIVE X FIRST DERIVATIVE Y HORIZ EDGE LAPLACIAN EDGE SECOND DERIVATIVE X SECOND DERIVATIVE XY SECOND DERIVATIVE Y SHARPEN SMOOTH VERT EDGE DEFAULT DEFAULT EDGE DETECT EDGE DETECT SQR FIRST DERIVATIVE X FIRST DERIVATIVE Y HORIZ EDGE LAPLACIAN EDGE SECOND DERIVATIVE X SECOND DERIVATIVE XY SECOND DERIVATIVE Y SHARPEN SMOOTH VERT EDGE DEFAULT