MF_spectrum MD_spectrum ME_spectrum
MFb_spectrum MDb_spectrum MEb_spectrum
MFb_spectrum_sizeBuf MDb_spectrum_sizeBuf MEb_spectrum_sizeBuf
Functionspatial frequency spectrum
Syntax C/C++#include <MFstd.h>
void MF_spectrum( fMatrix MSpec, ui htSpec, ui lenSpec, fMatrix MX, ui htX, ui lenX, fMatrix Win );
void MFb_spectrum( fMatrix MSpec, ui htSpec, ui lenSpec, fMatrix MX, ui htX, ui lenX, fMatrix Win, fVector Buf );
ui MFb_spectrum_sizeBuf( ui htSpec, ui lenSpec, ui htX, ui lenX );
C++ MatObj#include <OptiVec.h>
void matrix<T>::spectrum( const matrix<T>& MX, const matrix<T>& MWin );
void matrix<T>::b_spectrum( const matrix<T>& MX, const matrix<T>& MWin, vector<T> Buf );
Pascal/Delphiuses MFstd;
procedure MF_spectrum( MSpec:fMatrix; htSpec, lenSpec:UIntSize; MX:fMatrix; htX, lenX:UIntSize; MWin:fMatrix );
procedure MFb_spectrum( MSpec:fMatrix; htSpec, lenSpec:UIntSize; MX:fMatrix; htX, lenX:UIntSize; MWin:fMatrix; Buf:fVector );
function MFb_spectrum_sizeBuf( htSpec, lenSpec, htX, lenX:UIntSize ): UIntSize;
CUDA function C/C++#include <cudaMFstd.h>
int cudaMF_spectrum( fMatrix d_MSpec, ui htSpec, ui lenSpec, fMatrix d_MX, ui htX, ui lenX, fMatrix d_MWin );
void MFcu_spectrum( fMatrix h_MSpec, ui htSpec, ui lenSpec, fMatrix h_MX, ui htX, ui lenX, fMatrix h_MWin );
CUDA function Pascal/Delphiuses MFstd;
function cudaMF_spectrum( d_MSpec:fMatrix; htSpec, lenSpec:UIntSize; d_MX:fMatrix; htX, lenX:UIntSize; d_MWin:fMatrix ): IntBool;

procedure MFcu_spectrum( h_MSpec:fMatrix; htSpec, lenSpec:UIntSize; h_MX:fMatrix; htX, lenX:UIntSize; h_MWin:fMatrix );
DescriptionThe data set MX is analyzed for the mean square amplitude of its spatial frequency spectrum. The result is stored in MSpc.
Internally, the spectrum is calculated by dividing the input data into overlapping segments, similarly to the one-dimensional case described for VF_spectrum.
MWin is a window that is applied to the data segments. Three functions are available that give suitable Windows: MF_Welch,   MF_Parzen, and MF_Hann. A square window is available by setting all matrix elements equal to 1.0 (MF_equC( MWin, htSpec, lenSpec, 1.0 ); ), but this is not recommended.
htSpec and lenSpec must be integer powers of 2.
Moreover, the following conditions must be fulfilled:
htX >= n*htSpec, lenX >= n*lenSpec, htWin = htSpec, lenWin = lenSpec.

Internally, MF_spectrum allocates and frees additional workspace memory. For repeated calls, this would be inefficient. In such a case, it is recommended to use MFb_spectrum instead. The necessary size of Buf can be obtained by calling the function MFb_spectrum_sizeBuf. It will never need to be more than 4*htX*lenX. 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 htSpec or lenSpec is not a power of 2, VF_FFT (on which MF_spectrum relies) complains "Size must be an integer power of 2" and the program is aborted. If MSpc overwrites MX or MWin, an error message "Vectors/matrices must not be identical" is generated and the program aborted.
See alsoMF_FFT,   MF_xspectrum,   MF_coherence,   MF_convolve,   MF_autocorr,   MF_xcorr,   MF_filter,   chapter 12

MatrixLib Table of Contents  OptiVec home