SigmaTransform
The SigmaTransform unifies various known signal processing transforms, like the STFT and the wavelet transform, differing only by a specific diffeomorphism.
 All Classes Namespaces Files Functions Variables Typedefs Friends Macros
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
SigmaTransform::SigmaTransform< N > Class Template Reference

#include <SigmaTransformN.h>

Public Member Functions

 SigmaTransform (diffFunc< N > sigma=NULL, const point< N > &winWidth=point< N >(0), const point< N > &Fs=point< N >(0), const point< N > &size=point< N >(0), const std::vector< point< N >> &steps=std::vector< point< N >>(0), actFunc< N > action=minus< N >, int const &numThreads=4)
 SigmaTransform (diffFunc< N > sigma=NULL, winFunc< N > window=NULL, const point< N > &Fs=point< N >(0), const point< N > &size=point< N >(0), const std::vector< point< N >> &steps=std::vector< point< N >>(0), actFunc< N > action=minus< N >, int const &numThreads=4)
SigmaTransformsetWindow (winFunc< N > window)
SigmaTransformsetSigma (diffFunc< N > sigma)
SigmaTransformsetAction (actFunc< N > action)
SigmaTransformsetFs (const point< N > &Fs)
SigmaTransformsetSize (const point< N > &size)
SigmaTransformsetWinWidth (const double &winWidth)
SigmaTransformsetNumThreads (const int &numThreads)
SigmaTransformsetSteps (const std::vector< point< N >> &steps)
cxVec & getCoeffs ()
cxVec & getWindows ()
cxVec & getReconstruction ()
SigmaTransformoperator() (cxVec const &sig)
SigmaTransformanalyze (cxVec const &sig, std::function< void(SigmaTransform *)> onFinish=NULL)
SigmaTransformsynthesize (std::function< void(SigmaTransform *obj)> onFinish=NULL)
cxVec & multiplier (cxVec const &sig, cxVec const &mask, std::function< void(SigmaTransform *)> onFinish=NULL)
cxVec & multiplier (cxVec const &sig, mskFunc< N > maskFunc, std::function< void(SigmaTransform *)> onFinish=NULL)
SigmaTransformapplyMask (const cxVec &mask)
SigmaTransformapplyMask (mskFunc< N > maskFunc)
void makeWindows ()
SigmaTransformasyncTransform (cxVec const &sig, std::function< void(SigmaTransform *)> onFinish)
SigmaTransformasyncInverseTransform (std::function< void(SigmaTransform *)> onFinish)
SigmaTransformasyncMultiplier (cxVec const &sig, cxVec const &mask, std::function< void(SigmaTransform *)> onFinish)
SigmaTransformasyncMultiplier (cxVec const &sig, mskFunc< N > maskFunc, std::function< void(SigmaTransform *)> onFinish)
SigmaTransformjoin ()
cxVec fft (cxVec const &in, int const &howmany=1)
void fft_inplace (cxVec &inout, int const &howmany=1)
cxVec ifft (cxVec const &in, int const &howmany=1)
void ifft_inplace (cxVec &inout, int const &howmany=1)

Protected Member Functions

void makeWarpedDomain ()
std::vector< point< N > > makeSpatialDomain ()
void makeWarpedGaussian ()
SigmaTransformapplyTransform (const cxVec &in)
SigmaTransformapplyInverseTransform ()
void fftN (fftw_complex *out, fftw_complex *in, const point< N > &size, const int &howmany=1, const int &DIR=FFTW_FORWARD)

Protected Attributes

std::function< cmpx(point< N >
const &)> 
m_window
std::function< point< N >point
< N >const &)> 
m_sigma
std::function< point< N >point
< N >const &, point< N >const &)> 
m_action
cxVec m_windows
cxVec m_coeff
cxVec m_reconstructed
point< N > m_size
point< N > m_fs
std::vector< point< N > > m_steps
std::vector< point< N > > m_domain
int m_numThreads
point< N > m_winWidth
std::map< std::string,
std::thread > 
m_threads
std::mutex m_mtx

Detailed Description

template<size_t N>
class SigmaTransform::SigmaTransform< N >

Class template for the N-dimensional SigmaTransform.

Specific instantations are also derived.

Definition at line 35 of file SigmaTransformN.h.

Constructor & Destructor Documentation

template<size_t N>
SigmaTransform::SigmaTransform< N >::SigmaTransform ( diffFunc< N >  sigma = NULL,
const point< N > &  winWidth = point<N>(0),
const point< N > &  Fs = point<N>(0),
const point< N > &  size = point<N>(0),
const std::vector< point< N >> &  steps = std::vector<point<N>>(0),
actFunc< N >  action = minus<N>,
int const &  numThreads = 4 
)
inline

Constructor, taking the width of a warped Gaussian window instead of a function handle.

Parameters
sigmaa function handle for the spectral diffeomorphism, NULL for identity (STFT in N dimensions)
winWidththe width of a warped Gaussian in N dimensions
Fsthe sampling frequency in N dimensions
sizethe size of the signals that are to be transformed in N dimensions
stepsvector containing the channels in the warped Fourier domain in N dimensions
actiona function handle for the "group action" performed in the warped Fourier domain, defaults to "subtraction"
numThreadsthe number of threads used for parallel processing (multiplications, additions as well as for FFTW), defaults to 4

Definition at line 48 of file SigmaTransformN.h.

template<size_t N>
SigmaTransform::SigmaTransform< N >::SigmaTransform ( diffFunc< N >  sigma = NULL,
winFunc< N >  window = NULL,
const point< N > &  Fs = point<N>(0),
const point< N > &  size = point<N>(0),
const std::vector< point< N >> &  steps = std::vector<point<N>>(0),
actFunc< N >  action = minus<N>,
int const &  numThreads = 4 
)
inline

Constructor, taking a function handle instead of the width of a warped Gaussian window.

Parameters
sigmaa function handle for the spectral diffeomorphism, NULL for identity (STFT in N dimensions)
windowa function handle for the window template function, NULL for a warped Gaussian
Fsthe sampling frequency in N dimensions
sizethe size of the signals that are to be transformed in N dimensions
stepsvector containing the channels in the warped Fourier domain in N dimensions
actiona function handle for the "group action" performed in the warped Fourier domain, defaults to "subtraction"
numThreadsthe number of threads used for parallel processing (multiplications, additions as well as for FFTW), defaults to 4

Definition at line 62 of file SigmaTransformN.h.

Member Function Documentation

template<size_t N>
SigmaTransform& SigmaTransform::SigmaTransform< N >::analyze ( cxVec const &  sig,
std::function< void(SigmaTransform< N > *)>  onFinish = NULL 
)
inline

Analyze a signal.

Parameters
sigthe signal as a complex vector
onFinisha callback-function to be called, when the work is done; defaults to NULL NOTE: if NOT NULL: the transform is executed asynchronously in a separate thread and the function returns immediately if NULL: the transfom is executed synchronously and blocks till finish
Returns
reference to the SigmaTransform-object
Exceptions
std::runtime_error

Definition at line 212 of file SigmaTransformN.h.

template<size_t N>
SigmaTransform& SigmaTransform::SigmaTransform< N >::applyInverseTransform ( )
inlineprotected

Applies the actual inverse transform in a multi-threaded manner.

Returns
reference to the SigmaTransform-object

Definition at line 652 of file SigmaTransformN.h.

template<size_t N>
SigmaTransform& SigmaTransform::SigmaTransform< N >::applyMask ( const cxVec &  mask)
inline

Multiplies the coefficients with a mask.

Parameters
maskthe mask as a complex vector (of the same size as the coefficient-vector)
Returns
reference to the SigmaTransform-object
Exceptions
std::runtime_error

Definition at line 276 of file SigmaTransformN.h.

template<size_t N>
SigmaTransform& SigmaTransform::SigmaTransform< N >::applyMask ( mskFunc< N >  maskFunc)
inline

Multiplies the coefficients with a mask, using a given masking function.

Parameters
maskFunccomplex function handle, taking spatial and warped Fourier domain parameters
Returns
reference to the SigmaTransform-object

Definition at line 310 of file SigmaTransformN.h.

template<size_t N>
SigmaTransform& SigmaTransform::SigmaTransform< N >::applyTransform ( const cxVec &  in)
inlineprotected

Applies the actual transform in a multi-threaded manner.

Parameters
inthe signal as a complex vector
Returns
reference to the SigmaTransform-object

Definition at line 615 of file SigmaTransformN.h.

template<size_t N>
SigmaTransform& SigmaTransform::SigmaTransform< N >::asyncInverseTransform ( std::function< void(SigmaTransform< N > *)>  onFinish)
inline

Performs the synthesis/inverse transform asynchronously.

Parameters
onFinisha callback-function to be called, when the work is done
Returns
reference to the SigmaTransform-object

Definition at line 400 of file SigmaTransformN.h.

template<size_t N>
SigmaTransform& SigmaTransform::SigmaTransform< N >::asyncMultiplier ( cxVec const &  sig,
cxVec const &  mask,
std::function< void(SigmaTransform< N > *)>  onFinish 
)
inline

Performs the multiplier asynchronously.

Parameters
sigsignal as a complex vector
maskcomplex mask vector of the same size as the coefficient-vector
onFinisha callback-function to be called, when the work is done
Returns
reference to the SigmaTransform-object

Definition at line 422 of file SigmaTransformN.h.

template<size_t N>
SigmaTransform& SigmaTransform::SigmaTransform< N >::asyncMultiplier ( cxVec const &  sig,
mskFunc< N >  maskFunc,
std::function< void(SigmaTransform< N > *)>  onFinish 
)
inline

Performs the multiplier asynchronously.

Parameters
sigsignal as a complex vector
maskFunca function handle for the masking function
onFinisha callback-function to be called, when the work is done
Returns
reference to the SigmaTransform-object

Definition at line 444 of file SigmaTransformN.h.

template<size_t N>
SigmaTransform& SigmaTransform::SigmaTransform< N >::asyncTransform ( cxVec const &  sig,
std::function< void(SigmaTransform< N > *)>  onFinish 
)
inline

Performs the analysis/transform asynchronously.

Parameters
sigsignal as a complex vector
onFinisha callback-function to be called, when the work is done
Returns
reference to the SigmaTransform-object

Definition at line 380 of file SigmaTransformN.h.

template<size_t N>
cxVec SigmaTransform::SigmaTransform< N >::fft ( cxVec const &  in,
int const &  howmany = 1 
)
inline

Forward fft - wrapper for fftN.

Parameters
incomplex input vector
howmanynumber of signals of size "size", found in the input vector
Returns
complex output vector holding the transformed data

Definition at line 492 of file SigmaTransformN.h.

template<size_t N>
void SigmaTransform::SigmaTransform< N >::fft_inplace ( cxVec &  inout,
int const &  howmany = 1 
)
inline

Forward fft for inplace transform - wrapper for fftN.

Parameters
inoutcomplex input and output vector
howmanynumber of signals of size "size", found in the input vector
Returns
void

Definition at line 510 of file SigmaTransformN.h.

template<size_t N>
void SigmaTransform::SigmaTransform< N >::fftN ( fftw_complex *  out,
fftw_complex *  in,
const point< N > &  size,
const int &  howmany = 1,
const int &  DIR = FFTW_FORWARD 
)
inlineprotected

Wrapper for the N-dimensional Fast Fourier Transform from the FFTW Lib.

Parameters
outpointer to buffer, where the complex and transformed data is to be placed
inpointer to buffer, where the complex data is stored
sizesize of the signal to be transformed
howmanynumber of signals of size "size", found in the buffer "in"
DIRdirection of the transform
Returns
reference to the SigmaTransform-object

Definition at line 685 of file SigmaTransformN.h.

template<size_t N>
cxVec& SigmaTransform::SigmaTransform< N >::getCoeffs ( )
inline

Getter method for the transform-coefficients.

Returns
reference to the transform coefficients

Definition at line 178 of file SigmaTransformN.h.

template<size_t N>
cxVec& SigmaTransform::SigmaTransform< N >::getReconstruction ( )
inline

Getter method for the reconstruction

Returns
reference to the reconstructed signal

Definition at line 190 of file SigmaTransformN.h.

template<size_t N>
cxVec& SigmaTransform::SigmaTransform< N >::getWindows ( )
inline

Getter method for the spectrum of the windows

Returns
reference to the spectrums of the used windows

Definition at line 184 of file SigmaTransformN.h.

template<size_t N>
cxVec SigmaTransform::SigmaTransform< N >::ifft ( cxVec const &  in,
int const &  howmany = 1 
)
inline

Inverse fft - wrapper for fftN.

Parameters
incomplex input vector
howmanynumber of signals of size "size", found in the input vector
Returns
complex output vector holding the transformed data

Definition at line 524 of file SigmaTransformN.h.

template<size_t N>
void SigmaTransform::SigmaTransform< N >::ifft_inplace ( cxVec &  inout,
int const &  howmany = 1 
)
inline

Inverse fft for inplace transform - wrapper for fftN.

Parameters
inoutcomplex input and output vector
howmanynumber of signals of size "size", found in the input vector
Returns
void

Definition at line 542 of file SigmaTransformN.h.

template<size_t N>
SigmaTransform& SigmaTransform::SigmaTransform< N >::join ( )
inline

Waits for the asynchronous-threads to join and finally deltes them.

Returns
reference to the SigmaTransform-object

Definition at line 462 of file SigmaTransformN.h.

template<size_t N>
std::vector<point<N> > SigmaTransform::SigmaTransform< N >::makeSpatialDomain ( )
inlineprotected

Generates a Spatial domain, from the size and the sampling frequency

Returns
reference to the SigmaTransform-object

Definition at line 571 of file SigmaTransformN.h.

template<size_t N>
void SigmaTransform::SigmaTransform< N >::makeWarpedDomain ( )
inlineprotected

Generates a warped Fourier domain, from the spectral diffeomorphism and the sampling frequency.

Returns
reference to the SigmaTransform-object

Definition at line 555 of file SigmaTransformN.h.

template<size_t N>
void SigmaTransform::SigmaTransform< N >::makeWarpedGaussian ( )
inlineprotected

Generates a warped Gaussian window of adequate size.

Returns
reference to the SigmaTransform-object

Definition at line 585 of file SigmaTransformN.h.

template<size_t N>
void SigmaTransform::SigmaTransform< N >::makeWindows ( )
inline

Creates a set of "m_steps.size()" windows in the Fourier domain.

Returns
reference to the SigmaTransform-object

Definition at line 343 of file SigmaTransformN.h.

template<size_t N>
cxVec& SigmaTransform::SigmaTransform< N >::multiplier ( cxVec const &  sig,
cxVec const &  mask,
std::function< void(SigmaTransform< N > *)>  onFinish = NULL 
)
inline

Use transform as a multiplier; analyze, apply a mask and synthesize.

Parameters
sigthe signal as a complex vector
maskthe mask as a complex vector (of the same size as the coefficient-vector)
onFinisha callback-function to be called, when the work is done; defaults to NULL NOTE: if NOT NULL: the multiplier is executed asynchronously in a separate thread and the function returns immediately if NULL: the multiplier is executed synchronously and blocks till finish
Returns
reference to the SigmaTransform-object

Definition at line 249 of file SigmaTransformN.h.

template<size_t N>
cxVec& SigmaTransform::SigmaTransform< N >::multiplier ( cxVec const &  sig,
mskFunc< N >  maskFunc,
std::function< void(SigmaTransform< N > *)>  onFinish = NULL 
)
inline

Use transform as a multiplier; analyze, apply a mask and synthesize.

Parameters
sigthe signal as a complex vector
maskFunccomplex function handle, taking spatial and warped Fourier domain parameters
onFinisha callback-function to be called, when the work is done; defaults to NULL NOTE: if NOT NULL: the multiplier is executed asynchronously in a separate thread and the function returns immediately if NULL: the multiplier is executed synchronously and blocks till finish
Returns
reference to the SigmaTransform-object

Definition at line 264 of file SigmaTransformN.h.

template<size_t N>
SigmaTransform& SigmaTransform::SigmaTransform< N >::operator() ( cxVec const &  sig)
inline

Functor operator, wrapping "analyze".

Parameters
sigthe signal as a complex vector
Returns
reference to the SigmaTransform-object

Definition at line 198 of file SigmaTransformN.h.

template<size_t N>
SigmaTransform& SigmaTransform::SigmaTransform< N >::setAction ( actFunc< N >  action)
inline

Setter method for the action function handle.

Parameters
actiona function handle for the "group action" performed in the warped Fourier domain, defaults to "subtraction"
Returns
reference to the SigmaTransform-object

Definition at line 94 of file SigmaTransformN.h.

template<size_t N>
SigmaTransform& SigmaTransform::SigmaTransform< N >::setFs ( const point< N > &  Fs)
inline

Setter method for the sampling frequency

Parameters
Fsthe sampling frequency in N dimensions
Returns
reference to the SigmaTransform-object

Definition at line 102 of file SigmaTransformN.h.

template<size_t N>
SigmaTransform& SigmaTransform::SigmaTransform< N >::setNumThreads ( const int &  numThreads)
inline

Setter method for the number of threads

Parameters
numThreadsthe number of threads used for parallel processing (multiplications, additions as well as for FFTW), defaults to 4
Returns
reference to the SigmaTransform-object

Definition at line 126 of file SigmaTransformN.h.

template<size_t N>
SigmaTransform& SigmaTransform::SigmaTransform< N >::setSigma ( diffFunc< N >  sigma)
inline

Setter method for the spectral diffeomorphism function handle.

Parameters
sigmaa function handle for the spectral diffeomorphism, NULL for identity (STFT in N dimensions)
Returns
reference to the SigmaTransform-object

Definition at line 86 of file SigmaTransformN.h.

template<size_t N>
SigmaTransform& SigmaTransform::SigmaTransform< N >::setSize ( const point< N > &  size)
inline

Setter method for the signal size

Parameters
sizethe size of the signals that are to be transformed in N dimensions
Returns
reference to the SigmaTransform-object

Definition at line 110 of file SigmaTransformN.h.

template<size_t N>
SigmaTransform& SigmaTransform::SigmaTransform< N >::setSteps ( const std::vector< point< N >> &  steps)
inline

Setter method for the channels used in the warped Fourier domain

Parameters
stepsvector containing the channels in the warped Fourier domain in N dimensions
Returns
reference to the SigmaTransform-object
Exceptions
std::runtime_error

Definition at line 137 of file SigmaTransformN.h.

template<size_t N>
SigmaTransform& SigmaTransform::SigmaTransform< N >::setWindow ( winFunc< N >  window)
inline

Setter method for the window function handle.

Parameters
windowa function handle for the window function, NULL for warped Gaussian
Returns
reference to the SigmaTransform-object

Definition at line 78 of file SigmaTransformN.h.

template<size_t N>
SigmaTransform& SigmaTransform::SigmaTransform< N >::setWinWidth ( const double &  winWidth)
inline

Setter method for the window width

Parameters
winWidththe width of a warped Gaussian in N dimensions
Returns
reference to the SigmaTransform-object

Definition at line 118 of file SigmaTransformN.h.

template<size_t N>
SigmaTransform& SigmaTransform::SigmaTransform< N >::synthesize ( std::function< void(SigmaTransform< N > *obj)>  onFinish = NULL)
inline

synthesize from the coefficients, using the (complex conjugated) spectrum of the generated windows.

Parameters
onFinisha callback-function to be called, when the work is done; defaults to NULL NOTE: if NOT NULL: the inverse transform is executed asynchronously in a separate thread and the function returns immediately if NULL: the inverse transfom is executed synchronously and blocks till finish
Returns
reference to the SigmaTransform-object

Definition at line 234 of file SigmaTransformN.h.

Member Data Documentation

template<size_t N>
std::function<point<N>point<N>const&,point<N>const&)> SigmaTransform::SigmaTransform< N >::m_action
protected

Definition at line 699 of file SigmaTransformN.h.

template<size_t N>
cxVec SigmaTransform::SigmaTransform< N >::m_coeff
protected

Definition at line 703 of file SigmaTransformN.h.

template<size_t N>
std::vector<point<N> > SigmaTransform::SigmaTransform< N >::m_domain
protected

Definition at line 710 of file SigmaTransformN.h.

template<size_t N>
point<N> SigmaTransform::SigmaTransform< N >::m_fs
protected

Definition at line 708 of file SigmaTransformN.h.

template<size_t N>
std::mutex SigmaTransform::SigmaTransform< N >::m_mtx
protected

Definition at line 716 of file SigmaTransformN.h.

template<size_t N>
int SigmaTransform::SigmaTransform< N >::m_numThreads
protected

Definition at line 711 of file SigmaTransformN.h.

template<size_t N>
cxVec SigmaTransform::SigmaTransform< N >::m_reconstructed
protected

Definition at line 704 of file SigmaTransformN.h.

template<size_t N>
std::function<point<N>point<N>const&)> SigmaTransform::SigmaTransform< N >::m_sigma
protected

Definition at line 698 of file SigmaTransformN.h.

template<size_t N>
point<N> SigmaTransform::SigmaTransform< N >::m_size
protected

Definition at line 707 of file SigmaTransformN.h.

template<size_t N>
std::vector<point<N> > SigmaTransform::SigmaTransform< N >::m_steps
protected

Definition at line 709 of file SigmaTransformN.h.

template<size_t N>
std::map<std::string,std::thread> SigmaTransform::SigmaTransform< N >::m_threads
protected

Definition at line 715 of file SigmaTransformN.h.

template<size_t N>
std::function<cmpx(point<N>const&)> SigmaTransform::SigmaTransform< N >::m_window
protected

Definition at line 697 of file SigmaTransformN.h.

template<size_t N>
cxVec SigmaTransform::SigmaTransform< N >::m_windows
protected

Definition at line 702 of file SigmaTransformN.h.

template<size_t N>
point<N> SigmaTransform::SigmaTransform< N >::m_winWidth
protected

Definition at line 712 of file SigmaTransformN.h.


The documentation for this class was generated from the following file: