LabWindows/CVI

Table of Contents
  • LabWindows/CVI Fundamentals
  • Creating Applications
  • Distributing Applications
  • Library Reference
  • Programmer Reference
  • Hardware Information

CxConvolve2D

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 mM1 or n < 0 or nN1

and

y(m,n), m < 0 or mM2 or n < 0 or nN2.

When algorithm is ALGORITHM_CONCOR_FREQ_DOMAIN, this function completes the following steps, in order, to compute the two-dimensional convolution:

  1. 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.


  2. Second, this function calculates the Fourier transform of arrayX' and arrayY' according to the following equations.

    arrayX'(f) = FFT(x')
    arrayY'(f) = FFT(y')
  3. 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.

loc_eps_convol1b.gif

  1. OUTPUT_SIZE_FULL

    The output matrix arrayX * arrayY is (M1 + M2 – 1)-by-(N1 + N2 – 1).
  2. 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.
  3. 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 (M1M2 + 1)-by-(N1N2 + 1) matrix is the central part of the output matrix when outputSize is OUTPUT_SIZE_SIZE_X.
Note 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.

Constant Value Description
OUTPUT_SIZE_FULL 0 The size of outputArray is (M1 + M2 – 1)-by-(N1 + N2 – 1)
OUTPUT_SIZE_SIZE_X 1 The size of outputArray is the same as arrayX; that is M1-by-N1.
OUTPUT_SIZE_COMPACT 2 The size of outputArray (M1M2 + 1)-by-(N1N2 + 1). Note that in this mode m1 must be greater than or equal to m2 and n1 must be greater than or equal to n2.
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.

Constant Value Description
ALGORITHM_CONCOR_DIRECT 0 Computes the convolution using the direct method of linear convolution. If arrayX and arrayY are small, the ALGORITHM_CONCOR_DIRECT convolution method is typically faster.
ALGORITHM_CONCOR_FREQ_DOMAIN 1 Computes the convolution using an FFT-based technique. If arrayX and arrayY are large, the ALGORITHM_CONCOR_FREQ_DOMAIN convolution method is typically faster.
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

Log in to get a better experience