MF_xcorr MD_xcorr ME_xcorr
Functionspatial cross-correlation function
Syntax C/C++#include <MFstd.h>
void MF_xcorr( fMatrix MC, fMatrix MA, fMatrix MB, ui ht, ui len );
C++ MatObj#include <OptiVec.h>
void matrix<T>::xcorr( const matrix<T>& MA, const matrix<T>& MB );
Pascal/Delphiuses MFstd;
procedure MF_xcorr( MC, MA, MB:fMatrix; ht, len:UIntSize );
CUDA function C/C++#include <cudaMFstd.h>
int cudaMF_xcorr( fMatrix d_MC, fMatrix d_MA, fMatrix d_MB, ui ht, ui len );
void MFcu_xcorr( fMatrix h_MC, fMatrix h_MA, fMatrix h_MB, ui ht, ui len );
CUDA function Pascal/Delphiuses MFstd;
function cudaMF_xcorr( d_MC, d_MA, d_MB:fMatrix; ht, len:UIntSize ): IntBool;
procedure MFcu_xcorr( h_MC, h_MA, h_MB:fMatrix; ht, len:UIntSize );
DescriptionThe spatial cross-correlation function (SCCF) of MA and MB is calculated and stored in MC in wrap-around order in both dimensions: The row elements MCi,0 to MCi,len/2-1 contain the SCCF for zero and positive x lags. Beginning with the most negative lag in MCi,len/2+1, the elements up to MCi,len-1 contain the SCCF for negative lags. Since this function assumes MA and MB to be periodic, the SCCF for the most positive lag is identical to the SCCF for the most negative lag. This element is stored as MCi,len/2.
Similarly, the column elements MC0,j to MClen/2-1,j contain the SCCF for zero and positive y lags. Beginning with the most negative lag in MClen/2+1,j, the elements up to MClen-1,j contain the SCCF for negative lags.
To get the SCCF into normal order, you may call
MF_Rows_rotate( MC, ht, len, len/2 );
MF_Cols_rotate( MC, ht, len, ht/2 );

After that, the zero point is at the position MCht/2,len/2.
In case MA or MB are non-periodic, you should avoid end effects by the methods described in connection with MF_convolve.
All three matrices involved have the same dimensions. Both ht and len must be integer powers of 2.
About special versions with the prefixes MFl_ and MFs_, consult chapter 4.8 of
Error handlingIf either len or ht is not a power of 2, VF_FFT (on which MF_xcorr is based) complains "Size must be an integer power of 2" and the program is aborted.
See alsoMF_autocorr,   chapter 12

MatrixLib Table of Contents  OptiVec home