MF_filter MD_filter ME_filter
MCF_filter MCD_filter MCE_filter
MFb_filter MDb_filter MEb_filter
MCFb_filter MCDb_filter MCEb_filter
FunctionSpatial frequency filtering
Syntax C/C++#include <MFstd.h>
void MF_filter( fMatrix Y, fMatrix X, fMatrix Flt, ui ht, ui len );
void MFb_filter( fMatrix Y, fMatrix X, fMatrix Flt, ui ht, ui len, fVector Buf );
C++ MatObj#include <OptiVec.h>
void matrix<T>::filter( const matrix<T>& MX, const matrix<T>& MFlt );
void matrix<T>::b_filter( const matrix<T>& MX, const matrix<T>& MFlt, vector<T>& Buf );
Pascal/Delphiuses MFstd;
procedure MF_filter( MY, MX, MFlt:fMatrix; ht, len:UIntSize );
procedure MFb_filter( MY, MX, MFlt:fMatrix; ht, len:UIntSize; Buf:fVector );
CUDA function C/C++#include <cudaMFstd.h>
int cudaMF_filter( fMatrix d_MY, fMatrix d_MX, fMatrix d_MFlt, ui ht, ui len );
void MFcu_filter( fMatrix h_MY, fMatrix h_MX, fMatrix h_MFlt, ui ht, ui len );
CUDA function Pascal/Delphiuses MFstd;
function cudaMF_filter( d_MY, d_MX, d_MFlt:fMatrix; ht, len:UIntSize ): IntBool;
procedure MFcu_filter( h_MY, h_MX, h_MFlt:fMatrix; ht, len:UIntSize );
DescriptionA spatial frequency filter MFlt is applied to the matrix MX. Internally, this is done by performing a Fourier transform on MX, multiplying the transform with MFlt and transforming the product back into the space domain.

Complex versions: MX, MY and the filter MFlt are complex matrices.
Real versions: MX and MY are real. MFlt has to be in the packed complex format that is obtained by Fourier transforming a real matrix with MF_FFT (see that function for the description of the packed complex format) or by using MF_convolve.

If MX is non-periodic, the edges of the filtered function may be spoiled by wrap-around. See VF_convolve about how to avoid end-effects. As described there for vectors, embed the matrix MX in a larger matrix or remove a possible linear trends in both dimensions.

Internally, MF_filter allocates and frees additional workspace memory. For repeated calls, this would be inefficient. In such a case, it is recommended to use MFb_filter instead. The size of Buf must be:
C/C++, real:sizeof(Buf) >= ht*(len+4)
C/C++, complex:sizeof(Buf) >= ht*len
Pascal/Delphi, real or complex:  sizeof(Buf) >= ht*len

Additionally, Buf must be 128-bit (P8) or 256-bit (P9) aligned. This usually means you can only take a vector allocated by the VF_vector family as Buf.

Error handlingIf either ht or len is not a power of 2, VF_FFT (on which MF_filter is based) complains "Size must be an integer power of 2" and the program is aborted.
See alsoMF_FFT,   MF_convolve,   chapter 12,   chapter 4.8 of http://www.optivec.com/vecfuncs/

MatrixLib Table of Contents  OptiVec home