namespace referencePiiDsp
Routines for common digital signal processing tasks.
Classes
| struct |
A structure that stores information about a peak detected by findPeaks(). |
Enumerations
|
enum
|
{ FilterFull, FilterOriginalSize, FilterValidPart }
Filtering modes for convolution and relatives. |
|
enum
|
{ Haar, Daubechies }
Known wavelet families. |
Functions
|
template<class ResultType, class T, class U>
PiiMatrix< ResultType
>
|
Two-dimensional convolution of two matrices. |
|
template<class ResultType, class T, class U>
PiiMatrix< ResultType
>
|
Two-dimensional correlation of two matrices. |
|
template<class T>
|
Create an orthogonal wavelet filter set from the given scaling filter. |
|
PII_DSP_EXPORT PiiMatrix< double >
|
(
Get the indexth Daubechies scaling wavelet. |
|
template<class T>
PiiMatrix< T >
|
Perform a dyadic downsampling on the input matrix. |
|
template<class T>
|
Performs a two-dimensional one-level discrete wavelet transform on the input matrix. |
|
template<class T>
|
Performs a two-dimensional one-level discrete wavelet transform on the input matrix. |
|
template<class T>
PiiMatrix< T >
|
Swap opposing halves or quadrands of a matrix. |
|
template<class ResultType, class T, class U>
PiiMatrix< ResultType
>
|
Two-dimensional filter of two matrices. |
|
(
Find peaks in noisy one-dimensional data. |
|
|
template<class T>
PiiMatrix< T >
|
Take the central part of a matrix. |
|
template<class ResultType, class T, class U>
PiiMatrix< ResultType
>
|
Normalized cross-correlation of two-dimensional signals. |
|
template<class T>
PiiMatrix< T >
|
Compute a quadrature mirror filter for a filter. |
|
PII_DSP_EXPORT PiiMatrix< double >
|
Get the wavelet scaling filter for a certain mother wavelet. |
Enumeration details
-
enum FilterMode
Filtering modes for convolution and relatives.
-
FilterFull- full convolution/correlation. The size of the convolution between matrices A and B whose sizes are denoted by a and b is a+b-1 (A*B -> a+b-1). -
FilterOriginalSize- retain the size of the original matrix. (A*B -> a) -
FilterValidPart- return only those parts that can be computed without zero-padding. (A*B -> a-b+1, if a>b. Otherwise, an empty matrix is returned.)
-
-
enum WaveletFamily
Known wavelet families.
Families currently known are:
-
Haar - the Haar wavelet. Not actually a family, but equal to the first Daubechies wavelet.
-
Daubechies - Daubechies wavelet family
-
Function details
-
template<class ResultType, class T, class U>
PiiMatrix< ResultType > convolution
#include <PiiDsp.h>Two-dimensional convolution of two matrices.
The size of the resulting matrix will be (M+O-1)x(N+P-1) if the input matrices are of sizes MxN and OxP. Make sure b is not larger than a.
PiiMatrix<int> a(1,5, 1,2,3,4,5); PiiMatrix<int> b(1,3, -1, 0, 1); PiiMatrix<int> result = PiiDsp::convolution<int>(a, b); // result = -1 -2 -2 -2 -2 4 5
Parameters
- a
-
source matrix
- b
-
convolution filter
- mode
-
filtering mode
-
template<class ResultType, class T, class U>
PiiMatrix< ResultType > correlation
#include <PiiDsp.h>Two-dimensional correlation of two matrices.
The size of the resulting matrix will be (M+O-1)x(N+P-1) if the input matrices are of sizes MxN and OxP. Make sure that b is smaller than a.
Parameters
- a
-
source matrix
- b
-
correlation filter
- mode
-
filtering mode
See also
-
#include <PiiWavelet.h>Create an orthogonal wavelet filter set from the given scaling filter.
Parameters
- filter
-
a scaling filter for a wavelet
Returns
a list of four filters: decomposition low-pass, decomposition high-pass, reconstruction low-pass and reconstruction high-pass in this order.
-
PII_DSP_EXPORT PiiMatrix< double > daubechiesScalingFilter
(- int index
#include <PiiWavelet.h>Get the indexth Daubechies scaling wavelet.
The first filter (index 1) is a two-tap filter and equals to the Haar wavelet. Filter 2 is a four-tap filter, filter 3 a six-tap filter and so on.
Parameters
- index
-
filter index, must be in the range [1,10]
Returns
the filter coefficients as a row matrix
-
template<class T>
PiiMatrix< T > downSample
#include <PiiWavelet.h>Perform a dyadic downsampling on the input matrix.
Parameters
- mat
-
the input matrix
- directions
-
either Pii::Horizontally or Pii::Vertically, or both.
- odd
-
if one, odd rows and/or columns are removed. If zero, even rows and/or columns are removed
Returns
the input matrix with odd or even rows and/or columns removed
-
#include <PiiWavelet.h>Performs a two-dimensional one-level discrete wavelet transform on the input matrix.
Parameters
- mat
-
the input matrix
- lo
-
low-pass decomposition filter
- hi
-
high-pass decomposition filter
Returns
four matrices, the first one containing approximation coefficients and the last three containing horizontal, vertical and diagonal details in this order.
-
#include <PiiWavelet.h>Performs a two-dimensional one-level discrete wavelet transform on the input matrix.
Parameters
- mat
-
the input matrix
- wavelet
-
the wavelet family to be used (defaults to Haar).
- familyMember
-
the index of the wavelet within its family
Returns
four matrices, the first one containing approximation coefficients and the last three containing horizontal, vertical and diagonal details in this order.
-
#include <PiiDsp.h>Swap opposing halves or quadrands of a matrix.
This effectively moves the origin of a Fourier spectrum to the center of the matrix. Two successive calls restore the original matrix. If the matrix has an odd number of rows or columns, the original state will only be restored if the
inverseflag is set to true when shifting back. The figure below shows the matrix quadrants before (left) and after (right) shifting.+---+---+ +---+---+ | 1 | 2 | | 4 | 3 | +---+---+ -> +---+---+ | 3 | 4 | | 2 | 1 | +---+---+ +---+---+
Parameters
- matrix
-
the matrix to be shifted
- inverse
-
a flag that tells the direction of the shift. This is needed for matrices with an odd number of rows and columns.
Returns
shifted matrix
-
template<class ResultType, class T, class U>
PiiMatrix< ResultType > filter
#include <PiiDsp.h>Two-dimensional filter of two matrices.
The size of the resulting matrix will be (M+O-1)x(N+P-1) if the input matrices are of sizes MxN and OxP. Make sure that b is smaller than a. The type of the filter determines output type.
Parameters
- a
-
source matrix
- b
-
convolution filter
- mode
-
filtering mode
-
PII_DSP_EXPORT QList< Peak > findPeaks
(- const PiiMatrix< double > & data
- double levelThreshold
- double sharpnessThreshold = 1e-3
- int smoothWidth = 5
- int windowWidth = 7
#include <PiiDsp.h>Find peaks in noisy one-dimensional data.
This function locates and measures positive peaks in a noisy sequence of measurements by looking for sign changes in the smoothed first derivative of the input data. The exact location of the peak and its width are estimated by fitting a parabola to measurements around the zero crossing.
Parameters
- data
-
a row vector containing the measurements (e.g. a time series). If
datais a 2-by-N matrix, the first row will be treated as the x coordinate, and the second row as the y coordinate. If the data only contains the y coordinate (1-by-N row vector), the x is assumed to be in [0,N-1]. - levelThreshold
-
the mimimum value for a measurement to be regarded as a peak. This value cuts off peaks that are not high enough.
- sharpnessThreshold
-
the minimum relative value of the second derivative that will trigger peak detection. The relative derivative is calculated by dividing the second derivative by the corresponding measurement. This value cuts off peaks that are not sharp enough.
- smoothWidth
-
the width of a smoothing window that will be applied to the derivative before peak detection. Set to 1 or smaller to disable smoothing.
- windowWidth
-
the number of measurements considered in fitting the local parabola for accurate peak position. If this value is smaller than five, no fitting will be performed and no width estimate will be stored in the results. The width estimate becomes unreliable with a small window width.
Returns
a list of detected peaks or an empty list if no peaks were found. An empty list will be returned also if the peaks cannot be detected with the given parameters.
-
#include <PiiWavelet.h>Take the central part of a matrix.
Parameters
- mat
-
the matrix whose center is to be taken.
- rows
-
the number of rows in the returned matrix
- cols
-
the number of columns in the returned matrix
-
template<class ResultType, class T, class U>
PiiMatrix< ResultType > normalizedCorrelation
#include <PiiDsp.h>Normalized cross-correlation of two-dimensional signals.
Works analogously to correlation(), but normalizes the source signal
a. In normalized correlation, changing the level or scaling of the source signal will not affect the correlation result. -
#include <PiiWavelet.h>Compute a quadrature mirror filter for a filter.
The qmf is a reversed version of the input filter with every second item negated.
Parameters
- filter
-
the input filter
- odd
-
if one, odd elements are negated. Otherwise, even elements are negated.
Returns
the qmf filter
-
PII_DSP_EXPORT PiiMatrix< double > scalingFilter
#include <PiiWavelet.h>Get the wavelet scaling filter for a certain mother wavelet.
Parameters
- wavelet
-
the wavelet family
- member
Add a note
Not a single note added yet. Be the first, add yours.