CxConvolve2D
- Updated2023-02-21
- 4 minute(s) read
Advanced Analysis Library Only
AnalysisLibErrType CxConvolve2D (void *arrayX, ssize_t m1, ssize_t n1, void *arrayY, ssize_t m2, ssize_t n2, int outputSize, int algorithm, void *outputArray);
Purpose
Finds the 2D convolution of the complex input arrays.When algorithm is ALGORITHM_CONCOR_DIRECT, this function uses the following equation to compute the two-dimensional convolution of the input matrices arrayX and arrayY.
for i = 0, 1, 2, ..., M1 + M2 – 2 and j = 0, 1, 2, ..., N1 + N2 – 2
where h is arrayX * arrayY
M1 is the number of rows of matrix arrayX
N1 is the number of columns of matrix arrayX
M2 is the number of rows of matrix arrayY
N2 is the number of columns of matrix arrayY
The indexed elements outside the ranges of arrayX and arrayY are equal to zero, as shown in the following relationships:
x(m,n), m < 0 or m ≥ M1 or n < 0 or n ≥ N1
and
y(m,n), m < 0 or m ≥ M2 or n < 0 or n ≥ N2.
When algorithm is ALGORITHM_CONCOR_FREQ_DOMAIN, this function completes the following steps, in order, to compute the two-dimensional convolution:-
First, this function pads the end of arrayX and arrayY with zeros to make their sizes (M1 + M2 – 1)-by-(N1 + N2 – 2), as shown in the following equations.
-
Second, this function calculates the Fourier transform of arrayX' and arrayY' according to the following equations.
arrayX'(f) = FFT(x')
arrayY'(f) = FFT(y') -
Third, this function multiplies arrayX'(f) by arrayY'(f) and calculates the inverse Fourier transform of the product. The result is the two-dimensional convolution of arrayX and arrayY, as shown in the following equation.
arrayX * arrayY = IFFT(arrayX'(f) ⋅ arrayY'(f))
outputSize determines the size of the output matrix arrayX * arrayY as shown in the following illustration.

-
OUTPUT_SIZE_FULL
The output matrix arrayX * arrayY is (M1 + M2 – 1)-by-(N1 + N2 – 1). -
OUTPUT_SIZE_SIZE_X
This is useful in image processing. If arrayX is the image you want to filter, arrayY is a small matrix called the convolution kernel. arrayX * arrayY is the filtered image whose size is the same as that of image arrayX. The output M1-by-N1 matrix is the central part of the output matrix when outputSize is OUTPUT_SIZE_FULL. -
OUTPUT_SIZE_COMPACT
Computing the edge elements of arrayX * arrayY requires zero-padding if outputSize is OUTPUT_SIZE_FULL or OUTPUT_SIZE_SIZE_X. LabWindows/CVI removes these edge elements if outputSize is OUTPUT_SIZE_COMPACT. The output (M1 – M2 + 1)-by-(N1 – N2 + 1) matrix is the central part of the output matrix when outputSize is OUTPUT_SIZE_SIZE_X.
![]() |
Note This function temporarily allocates memory for use as a work area. If CxConvolve2D cannot allocate memory, the function returns an error code. |
Parameters
Input | ||||||||||||||
Name | Type | Description | ||||||||||||
arrayX | void * | First input array. | ||||||||||||
rowsInX | ssize_t | Number of rows in arrayX. | ||||||||||||
columnsInX | ssize_t | Number of columns in arrayX. | ||||||||||||
arrayY | void * | Second input array. | ||||||||||||
rowsInY | ssize_t | Number of rows in arrayY. | ||||||||||||
columnsInY | ssize_t | Number of columns in arrayY. | ||||||||||||
outputSize | int | The size of the output. outputSize must be one of the following values.
|
||||||||||||
algorithm | int | Specifies the convolution method to use. algorithm must be one of the following values. Note that slight numerical can exist between the two methods.
|
||||||||||||
Output | ||||||||||||||
Name | Type | Description | ||||||||||||
outputArray | void | Convolution array. The size of outputArray relates to outputSize. |
Return Value
Name | Type | Description |
status | AnalysisLibErrType | A value that specifies the type of error that occurred. Refer to analysis.h for definitions of these constants. |
Additional Information
Library: Advanced Analysis Library
Include file: analysis.h
LabWindows/CVI compatibility: LabWindows/CVI 2012 and later