Functions > Vector and Matrix > Other Array Functions > Convolution and Cross Correlation
Convolution and Cross Correlation
convolve(S, K, [BC], [OV])—Performs convolution between 2 vectors (1D) or 2 matrices (2D) with an arbitrary phase.
Convolution in time corresponds to multiplication in frequency, and vice versa, and is useful in digital filtering.
crosscorr(S, K, [BC], [OV])—Performs a cross correlation between 2 vectors (1D correlation) or 2 matrices (2D correlation) with an arbitrary phase.
Correlation is equivalent to convolution, with one sequence reversed in time, often used in finding the impulse response of a system.
The crosscorr function can be used to correlate images.
The crosscorr function combines the functionality of the deprecated functions correl and correl2d.
S is a vector or a matrix representing the input signal. The array elements can have real or complex values.
K is a vector or a matrix representing the kernel. The array elements can have real or complex values.
BC (optional) is an integer argument which dictates the type of convolution to be performed by specifying how to handle the matrix boundaries during correlation. BC can be set to 0 (default), 1, 2 or 3; where:
0: Linear (or Zero padding)—Pixels beyond matrix boundary are treated as zeros.
1: Circular (or Periodic wrapping)—Pixels beyond matrix boundary are treated as a periodic continuation of the matrix.
2: Reflection—Pixels beyond matrix boundary are treated as if reflected by mirrors along the edges of the matrix.
3: Continuation—Pixels beyond matrix boundary are taken to be the last value inside the matrix.
OV (optional) is an integer value or a vector of two integer values that dictates whether a shift of the second signal is applied. It is used to specify the initial row and column overlap (phase correlation) of the kernel matrix K with the input signal matrix S. The first element of the vector specifies the row overlap and the second specifies the column overlap.
The minimum overlap cannot be less than 1 and the maximum overlap cannot be larger than the kernel size.
For a zero phase correlation, the overlap must be defined so that the origin of the kernel is at the center of the kernel; assuming the kernel is an odd-sized matrix. For this case the two overlap parameters should be set to the number of rows and columns of the kernel minus their halves respectively.
For one dimensional cross correlation, the row overlap is set to 1.
For two dimensional cross correlation, the default overlap is set as follows:
Row_overlap = K_rows − K_rows/2
Column_overlap = K_columns − K_columns/2
Was this helpful?