[−][src]Function opencv::core::dct
pub fn dct(
src: &dyn ToInputArray,
dst: &mut dyn ToOutputArray,
flags: i32
) -> Result<()>
Performs a forward or inverse discrete Cosine transform of 1D or 2D array.
The function cv::dct performs a forward or inverse discrete Cosine transform (DCT) of a 1D or 2D floating-point array:
- Forward Cosine transform of a 1D vector of N elements: where and , for j > 0.
- Inverse Cosine transform of a 1D vector of N elements: (since is an orthogonal matrix, )
- Forward 2D Cosine transform of M x N matrix:
- Inverse 2D Cosine transform of M x N matrix:
The function chooses the mode of operation by looking at the flags and size of the input array:
- If (flags & #DCT_INVERSE) == 0 , the function does a forward 1D or 2D transform. Otherwise, it is an inverse 1D or 2D transform.
- If (flags & #DCT_ROWS) != 0 , the function performs a 1D transform of each row.
- If the array is a single column or a single row, the function performs a 1D transform.
- If none of the above is true, the function performs a 2D transform.
Note: Currently dct supports even-size arrays (2, 4, 6 ...). For data analysis and approximation, you can pad the array when necessary. Also, the function performance depends very much, and not monotonically, on the array size (see getOptimalDFTSize ). In the current implementation DCT of a vector of size N is calculated via DFT of a vector of size N/2 . Thus, the optimal DCT size N1 >= N can be calculated as:
ⓘThis example is not tested
size_t getOptimalDCTSize(size_t N) { return 2*getOptimalDFTSize((N+1)/2); } N1 = getOptimalDCTSize(N);
Parameters
- src: input floating-point array.
- dst: output array of the same size and type as src .
- flags: transformation flags as a combination of cv::DftFlags (DCT_*)
See also
dft , getOptimalDFTSize , idct
C++ default parameters
- flags: 0