Ocean
|
This class implements Fourier transformation functions. More...
Data Structures | |
class | NaiveImplementation |
This class provides the implementation of the Fourier transformation of the Ocean framework. More... | |
Static Public Member Functions | |
static bool | dft0 (const Frame &source, Frame &target, int flags, int nonzero_rows) |
Direct Fourier Transformation (OpenCV-compatible interface) More... | |
static bool | dft0 (const void *source, const unsigned int width, const unsigned int height, const unsigned int sourceChannels, void *target, const unsigned int targetChannels, const Ocean::FrameType::DataType dataType, int flags, int nonzero_rows, const unsigned int sourcePaddingElements=0u, const unsigned int targetPaddingElements=0u) |
Direct Fourier Transformation (OpenCV-compatible interface) More... | |
static int | getOptimalDFTSize0 (int size) |
Returns the optimal DFT size for a given vector size. More... | |
template<typename T > | |
static void | spatialToFrequency2 (const T *spatial, const unsigned int width, const unsigned int height, T *complexFrequency, const unsigned int spatialPaddingElements=0u, const unsigned int frequencyPaddingElements=0u) |
Applies a forward Fourier transformation for a given 2D (real) spatial signal. More... | |
template<typename T > | |
static void | complexSpatialToFrequency2 (const T *complexSpatial, const unsigned int width, const unsigned int height, T *complexFrequency, const unsigned int spatialPaddingElements=0u, const unsigned int frequencyPaddingElements=0u) |
Applies a forward Fourier transformation for a given 2D (complex) spatial signal. More... | |
template<typename T > | |
static void | frequencyToSpatial2 (const T *complexFrequency, const unsigned int width, const unsigned int height, T *spatial, const unsigned int frequencyPaddingElements=0u, const unsigned int spatialPaddingElements=0u) |
Applies a backward Fourier transformation for a given 2D frequency signal. More... | |
template<typename T > | |
static void | frequencyToComplexSpatial2 (const T *complexFrequency, const unsigned int width, const unsigned int height, T *complexSpatial, const unsigned int frequencyPaddingElements=0u, const unsigned int spatialPaddingElements=0u) |
Applies a backward Fourier transformation for a given 2D frequency signal. More... | |
template<typename TScalar , typename TComplex > | |
static void | scalarToComplex (const TScalar *source, std::complex< TComplex > *target, const size_t number) |
Converts scalar values to complex values. More... | |
template<typename TComplex , typename TScalar > | |
static void | realToScalar (const std::complex< TComplex > *source, TScalar *target, const size_t number) |
Converts the real components of complex values to scalar values. More... | |
template<typename TComplex , typename TScalar > | |
static void | imaginaryToScalar (const std::complex< TComplex > *source, TScalar *target, const size_t number) |
Converts the imaginary components of complex values to scalar values. More... | |
template<typename TComplex , typename TScalar > | |
static void | complexToMagnitude (const std::complex< TComplex > *source, TScalar *target, const size_t number) |
Converts complex values to magnitude (or absolute) values. More... | |
template<typename T > | |
static void | shiftHalfDimension2 (const T *source, unsigned int width, const unsigned int height, T *target) |
Shifts a given signal by half of the width and the height. More... | |
template<typename T > | |
static void | shiftHalfDimension2 (T *data, unsigned int width, const unsigned int height) |
Shifts a given signal by half of the width and the height. More... | |
static unsigned int | shiftCenter (const unsigned int size) |
Returns the center position for shift operations that corresponds with the first Fourier element. More... | |
template<typename T , bool tComplexConjugateA, bool tComplexConjugateB> | |
static void | elementwiseMultiplication2 (const T *complexSourceA, const T *complexSourceB, T *complexTarget, const unsigned int width, const unsigned int height, const unsigned int horizontalPaddingSourceAElements=0u, const unsigned int horizontalPaddingSourceBElements=0u, const unsigned int horizontalPaddingTargetElements=0u) |
Elementwise multiplication of two 2D complex Fourier spectrums (one channel spectrums). More... | |
template<typename TComplex , bool tComplexConjugateA, bool tComplexConjugateB, typename TIntermediate = double> | |
static void | elementwiseMultiplicationCCS (const TComplex *sourceA, const TComplex *sourceB, TComplex *target, const unsigned int width, const unsigned int height, const unsigned int horizontalPaddingSourceAElements=0u, const unsigned int horizontalPaddingSourceBElements=0u, const unsigned int horizontalPaddingTargetElements=0u) |
Multiplication of two 2D complex Fourier spectrums (one channel spectrums) in packed complex conjugate-symmetric format or CCS-packed format. More... | |
template<typename T > | |
static void | elementwiseDivision2 (const T *complexSourceA, const T *complexSourceB, T *complexTarget, const unsigned int width, const unsigned int height, const unsigned int horizontalPaddingSourceAElements=0u, const unsigned int horizontalPaddingSourceBElements=0u, const unsigned int horizontalPaddingTargetElements=0u) |
Elementwise division of two 2D complex Fourier spectrums (one channel spectrums). More... | |
This class implements Fourier transformation functions.
|
static |
Applies a forward Fourier transformation for a given 2D (complex) spatial signal.
complexSpatial | The complex 2D spatial signal that will be transformed, must be valid |
width | The width of the 2D signal in elements, with range [1, infinity) |
height | height of the 2D signal in elements, with range [1, infinity) |
complexFrequency | Resulting complex frequency analysis for the given signal, must be valid |
spatialPaddingElements | The number of padding elements at the end of each row of the spatial signal, in elements with respect to T (not complex<T> ), with range [0, infinity) |
frequencyPaddingElements | The number of padding elements at the end of each row of the frequency analysis, in elements (not complex<T> ), with range [0, infinity) |
T | Data type of the spatial and frequency signals, either 'float' or 'double' |
|
inlinestatic |
Converts complex values to magnitude (or absolute) values.
The magnitude of a complex value is determined by the square root of the squared sum of the real and the imaginary element.
source | Complex source values |
target | Resulting magnitude values, make sure that the provided memory is large enough |
number | Number of elements that will be converted |
TComplex | Data type of the complex signal |
TScalar | Data type of the real signal |
|
static |
Direct Fourier Transformation (OpenCV-compatible interface)
source | Input array that could be real or complex. Must be valid. |
target | Output array whose size and type depends on the flags. Size depends on flags . |
flags | Transformation flags, representing a combination of the cv::DftFlags |
nonzero_rows | Number of nonzero rows. All rows after that will be ignored. |
|
static |
Direct Fourier Transformation (OpenCV-compatible interface)
source | Input array that could be real or complex, must be a valid pointer |
width | The width of the input and output arrays, range: [1, infinity) |
height | The height of the input and output arrays, range: [1, infinity) |
sourceChannels | Number of channels of the input array, range: [1, 2] |
target | Output array, this must be initialized before calling this function, size depends on flags , must be a valid pointer |
targetChannels | Number of channels of the output array, depends on flags , range: [1, 2] |
dataType | Data type of the input and output (must be the same), valid values: FrameType::DT_SIGNED_FLOAT_32 or FrameType::DT_SIGNED_FLOAT_64 |
flags | Transformation flags, representing a combination of the cv::DftFlags |
nonzero_rows | Number of nonzero rows. All rows after that will be ignored |
sourcePaddingElements | Number of padding elements used in the input array, range: [0, infinity) |
targetPaddingElements | Number of padding elements used in the output array, range: [0, infinity) |
|
static |
Elementwise division of two 2D complex Fourier spectrums (one channel spectrums).
This function allows the definition of padding elements at the end of each row to support sub-specturms.
complexSourceA | The pointer of the first source spectrum, must be valid |
complexSourceB | The pointer of the second source spectrum, must be valid |
complexTarget | The pointer of the targt spectrum receiving the elementwise multiplication result, must be valid |
width | The width of the 2D spectrum (the number of complex elements in horizontal direction), with range [1, infinity) |
height | The height of the 2D specturm (the number of complex elements in vertical direction), with range [1, infinity) |
horizontalPaddingSourceAElements | Optional horizontal padding at the end of each row of the first source specturm, in elements with respect to T (not complex<T> ), with range [0, infinity) |
horizontalPaddingSourceBElements | Optional horizontal padding at the end of each row of the second source specturm, in elements with respect to T (not complex<T> ), with range [0, infinity) |
horizontalPaddingTargetElements | Optional horizontal padding at the end of each row of the target specturm, in elements with respect to T (not complex<T> ), with range [0, infinity) |
T | The data type of the real and imaginary part of the complex number, e.g., 'float' or 'double' |
|
static |
Elementwise multiplication of two 2D complex Fourier spectrums (one channel spectrums).
complexSourceA | The pointer of the first complex source spectrum, must be valid |
complexSourceB | The pointer of the second complex source spectrum, must be valid |
complexTarget | The pointer of the target spectrum receiving the elementwise multiplication result, must be valid |
width | The width of the 2D spectrum (the number of complex elements in horizontal direction), with range [1, infinity) |
height | The height of the 2D specturm (the number of complex elements in vertical direction), with range [1, infinity) |
horizontalPaddingSourceAElements | Optional horizontal padding at the end of each row of the first source specturm, in elements with respect to T (not complex<T> ), with range [0, infinity) |
horizontalPaddingSourceBElements | Optional horizontal padding at the end of each row of the second source specturm, in elements with respect to T (not complex<T> ), with range [0, infinity) |
horizontalPaddingTargetElements | Optional horizontal padding at the end of each row of the target specturm, in elements with respect to T (not complex<T> ), with range [0, infinity) |
T | The data type of the real and imaginary part of the complex number, e.g., 'float' or 'double' |
tComplexConjugateA | True, to multiply the complex conjugated values of the first spectrum; False, to multiply the first spectrum without modification |
tComplexConjugateB | True, to multiply the complex conjugated values of the first spectrum; False, to multiply the second spectrum without modification |
|
static |
Multiplication of two 2D complex Fourier spectrums (one channel spectrums) in packed complex conjugate-symmetric format or CCS-packed format.
For 2D one-channel data, the packed conjugate-symmetric format (CCS-packed format) is defined as follows:
Even width, \(w = 2L\), and even height, \(h = 2K\)
\[\begin{bmatrix} R_{0,0} & R_{0,1} & I_{0,1} & R_{0,2} & \cdots & I_{0,L-1} & R_{0,L} \\ R_{1,0} & R_{1,1} & I_{1,1} & R_{1,2} & \cdots & I_{1,L-1} & R_{1,L} \\ I_{1,0} & R_{2,1} & I_{2,1} & R_{2,2} & \cdots & I_{2,L-1} & I_{1,L} \\ R_{2,0} & R_{3,1} & I_{3,1} & R_{3,2} & \cdots & I_{3,L-1} & R_{2,L} \\ \cdots & \cdots & \cdots & \cdots & \cdots & \cdots & \cdots \\ I_{K-1,0} & R_{2K-2,1} & I_{2K-2,1} & R_{2K-2,2} & \cdots & I_{2K-2,L-1} & I_{K-1,L} \\ R_{K,0} & R_{2K-1,1} & I_{2K-1,1} & R_{2K-1,2} & \cdots & I_{2K-1,L-1} & R_{K-1,L} \\ \end{bmatrix}\in\mathbb{R}^{h \times w}\]
Even width, \(w = 2L\), and odd height, \(h = 2K + 1\)
\[\begin{bmatrix} R_{0,0} & R_{0,1} & I_{0,1} & R_{0,2} & \cdots & I_{0,L-1} & R_{0,L} \\ R_{1,0} & R_{1,1} & I_{1,1} & R_{1,2} & \cdots & I_{1,L-1} & R_{1,L} \\ I_{1,0} & R_{2,1} & I_{2,1} & R_{2,2} & \cdots & I_{2,L-1} & I_{1,L} \\ R_{2,0} & R_{3,1} & I_{3,1} & R_{3,2} & \cdots & I_{3,L-1} & R_{2,L} \\ \cdots & \cdots & \cdots & \cdots & \cdots & \cdots & \cdots \\ I_{K-1,0} & R_{2K-2,1} & I_{2K-2,1} & R_{2K-2,2} & \cdots & I_{2K-2,L-1} & I_{K-1,L} \\ R_{K,0} & R_{2K-1,1} & I_{2K-1,1} & R_{2K-1,2} & \cdots & I_{2K-1,L-1} & R_{K-1,L} \\ I_{K,0} & R_{2K,1} & I_{2K,1} & R_{2K,2} & \cdots & I_{2K,L-1} & I_{K,L} \\ \end{bmatrix}\in\mathbb{R}^{h \times w}\]
Odd width, \(w = 2L + 1\), and even height, \(h = 2K\)
\[\begin{bmatrix} R_{0,0} & R_{0,1} & I_{0,1} & R_{0,2} & \cdots & I_{0,L-1} & R_{0,L} & I_{0,L} \\ R_{1,0} & R_{1,1} & I_{1,1} & R_{1,2} & \cdots & I_{1,L-1} & R_{1,L} & I_{1,L} \\ I_{1,0} & R_{2,1} & I_{2,1} & R_{2,2} & \cdots & I_{2,L-1} & R_{2,L} & I_{2,L} \\ R_{2,0} & R_{3,1} & I_{3,1} & R_{3,2} & \cdots & I_{3,L-1} & R_{3,L} & I_{3,L} \\ \cdots & \cdots & \cdots & \cdots & \cdots & \cdots & \cdots & \cdots \\ I_{K-1,0} & R_{2K-2,1} & I_{2K-2,1} & R_{2K-2,2} & \cdots & I_{2K-2,L-1} & R_{2K-2,L} & I_{2K-2,L} \\ R_{K,0} & R_{2K-1,1} & I_{2K-1,1} & R_{2K-1,2} & \cdots & I_{2K-1,L-1} & R_{2K-1,L} & I_{2K-1,L} \\ \end{bmatrix}\in\mathbb{R}^{h \times w}\]
Odd width, \(w = 2L + 1\), and odd height, \(h = 2K + 1\)
\[\begin{bmatrix} R_{0,0} & R_{0,1} & I_{0,1} & R_{0,2} & \cdots & I_{0,L-1} & R_{0,L} & I_{0,L} \\ R_{1,0} & R_{1,1} & I_{1,1} & R_{1,2} & \cdots & I_{1,L-1} & R_{1,L} & I_{1,L} \\ I_{1,0} & R_{2,1} & I_{2,1} & R_{2,2} & \cdots & I_{2,L-1} & R_{2,L} & I_{2,L} \\ R_{2,0} & R_{3,1} & I_{3,1} & R_{3,2} & \cdots & I_{3,L-1} & R_{3,L} & I_{3,L} \\ \cdots & \cdots & \cdots & \cdots & \cdots & \cdots & \cdots & \cdots \\ I_{K-1,0} & R_{2K-2,1} & I_{2K-2,1} & R_{2K-2,2} & \cdots & I_{2K-2,L-1} & R_{2K-2,L} & I_{2K-2,L} \\ R_{K,0} & R_{2K-1,1} & I_{2K-1,1} & R_{2K-1,2} & \cdots & I_{2K-1,L-1} & R_{2K-1,L} & I_{2K-1,L} \\ I_{K,0} & R_{2K,1} & I_{2K,1} & R_{2K,2} & \cdots & I_{2K,L-1} & R_{2K,L} & I_{2K,L} \\ \end{bmatrix}\in\mathbb{R}^{h \times w}\]
For 1D one-channel data, the format is defined as:
Even length, \(l = \textbf{max}(w, h) = 2L\)
\[\begin{bmatrix} R_{0} & R_{1} & I_{1} & R_{2} & \cdots & I_{L-1} & R_{L} \end{bmatrix}\in\mathbb{R}^{l}\]
Odd length, \(l = \textbf{max}(w, h) = 2L + 1\)
\[\begin{bmatrix} R_{0} & R_{1} & I_{1} & R_{2} & \cdots & I_{L-1} & R_{L} & I_{L} \end{bmatrix}\in\mathbb{R}^{l}\]
The input data is expected to be in the CCS-packed format. The output is guaranteed to be in the CCS-packed format.
More resources about the complex conjugate-symmetric format:
cv::multspectums()
(requires that TIntermediate=double
). For 2D two-channel input refer to the above function elementwiseMultiplication2()
. cv::dft()
sourceA | The pointer of the first source spectrum, must be valid |
sourceB | The pointer of the second source spectrum, must be valid |
target | The pointer of the targt spectrum receiving the elementwise multiplication result, must be valid |
width | The width of the input and output spectra, with range [1, infinity) |
height | The height of the input and output spectra, with range [1, infinity) |
horizontalPaddingSourceAElements | Optional horizontal padding at the end of each row of the first source specturm (number of complex elements), with range [0, infinity) |
horizontalPaddingSourceBElements | Optional horizontal padding at the end of each row of the second source specturm (number of complex elements), with range [0, infinity) |
horizontalPaddingTargetElements | Optional horizontal padding at the end of each row of the target specturm (number of complex elements), with range [0, infinity) |
TComplex | Type of the real and imaginary parts of the complex numbers |
tComplexConjugateA | If true, the conjugated values of sourceA will be used in the multiplication, otherwise they will be used as is |
tComplexConjugateB | If true, the conjugated values of sourceB will be used in the multiplication, otherwise they will be used as is |
TIntermediate | Type that is used internally for the computation. Size of this can be larger than TComplex which helps reduce float rounding errors. |
|
static |
Applies a backward Fourier transformation for a given 2D frequency signal.
complexFrequency | The complex 2D frequency signal that will be transformed, must be valid |
width | The width of the 2D signal in elements, with range [1, infinity) |
height | height of the 2D signal in elements, with range [1, infinity) |
complexSpatial | Resulting complex spatial frequency for the given signal, make sure that the provided buffer is large enough, must be valid |
frequencyPaddingElements | The number of padding elements at the end of each row of the frequency analysis, in elements (not complex<T> ), with range [0, infinity) |
spatialPaddingElements | The number of padding elements at the end of each row of the spatial signal, in elements with respect to T (not complex<T> ), with range [0, infinity) |
T | Data type of the spatial and frequency signals, either 'float' or 'double' |
|
static |
Applies a backward Fourier transformation for a given 2D frequency signal.
complexFrequency | The complex 2D frequency signal that will be transformed, must be valid |
width | The width of the 2D signal in elements, with range [1, infinity) |
height | height of the 2D signal in elements, with range [1, infinity) |
spatial | Resulting (real) spatial frequency for the given signal, make sure that the provided buffer is large enough, must be valid |
frequencyPaddingElements | The number of padding elements at the end of each row of the frequency analysis, in elements (not complex<T> ), with range [0, infinity) |
spatialPaddingElements | The number of padding elements at the end of each row of the spatial signal, in elements with respect to T (not complex<T> ), with range [0, infinity) |
T | Data type of the spatial and frequency signals, either 'float' or 'double' |
|
static |
Returns the optimal DFT size for a given vector size.
size | The size of the vector |
|
inlinestatic |
Converts the imaginary components of complex values to scalar values.
source | Complex source values |
target | Resulting scalar values, make sure that the provided memory is large enough |
number | Number of elements that will be converted |
TComplex | Data type of the complex signal |
TScalar | Data type of the real signal |
|
inlinestatic |
Converts the real components of complex values to scalar values.
source | Complex source values |
target | Resulting scalar values, make sure that the provided memory is large enough |
number | Number of elements that will be converted |
TComplex | Data type of the complex signal |
TScalar | Data type of the real signal |
|
inlinestatic |
Converts scalar values to complex values.
source | Scalar source values |
target | Resulting complex values, make sure that the provided memory is large enough |
number | Number of elements that will be converted |
TScalar | Data type of the real signal |
TComplex | Data type of the complex signal |
|
inlinestatic |
Returns the center position for shift operations that corresponds with the first Fourier element.
size | Size of the signal in bins, with range (0, infinity) |
|
static |
Shifts a given signal by half of the width and the height.
source | The source signal that will be shifted |
width | The width of the signal in elements, must be even |
height | The height of the signal in elements, must be even |
target | The target signal that will receive the shifted signal |
T | Data type of the signal |
|
static |
Shifts a given signal by half of the width and the height.
data | Signal that will be shifted |
width | The width of the signal in elements, must be even |
height | The height of the signal in elements, must be even |
T | Data type of the signal |
|
static |
Applies a forward Fourier transformation for a given 2D (real) spatial signal.
spatial | The real 2D spatial signal that will be transformed, must be valid |
width | The width of the 2D signal in elements, with range [1, infinity) |
height | height of the 2D signal in elements, with range [1, infinity) |
complexFrequency | Resulting complex frequency analysis for the given signal, must be valid |
spatialPaddingElements | The number of padding elements at the end of each row of the spatial signal, in elements with respect to T (not complex<T> ), with range [0, infinity) |
frequencyPaddingElements | The number of padding elements at the end of each row of the frequency analysis, in elements (not complex<T> ), with range [0, infinity) |
T | The element data type of the spatial and frequency signals, either 'float' or 'double' |