| dctMatrix {mrbsizeR} | R Documentation |
Create a n-by-n discrete cosine transform matrix.
Description
The discrete cosine transform (DCT) matrix for a given dimension n is calculated.
Usage
dctMatrix(n)
Arguments
n |
Dimension for the DCT matrix. |
Details
The function can be used for 1D- or 2D-DCT transforms of data.
-
1D: Let
Qbe a m-by-n matrix with some data.Dis a m-by-m DCT matrix created bydctMatrix(m). ThenD %*% Qreturns the discrete cosine transform of the columns of Q.t(D) %*% Qreturns the inverse DCT of the columns of Q. As D is orthogonal,solve(D) = t(D). -
2D: Let
Qbe a m-by-n matrix with some data.D_mis a m-by-m DCT matrix created bydctMatrix(m),D_na n-by-n DCT matrix created bydctMatrix(n).D_m %*% Q %*% t(D_n)computes the 2D-DCT of Q. The inverse 2D-DCT of Q can be computed via
t(D_mm) %*% DCT_Q %*% D_n. D_m transforms along columns, D_n along rows. Since D is orthogonal,solve(D) = t(D).
It can be faster to use dctMatrix than using a direct transformation,
especially when calculating several DCT's.
Value
The n-by-n DCT matrix.
Examples
D <- dctMatrix(5)