returns an n×n discrete cosine transform matrix of type 2.
FourierDCTMatrix[n,m]
returns an n×n discrete cosine transform matrix of type m.
FourierDCTMatrix
returns an n×n discrete cosine transform matrix of type 2.
FourierDCTMatrix[n,m]
returns an n×n discrete cosine transform matrix of type m.
Details and Options
- Each entry Frs of the discrete cosine transform matrix of type m is computed as:
-
1. DCT-I 
2. DCT-II 
3. DCT-III 
4. DCT-IV 
- The discrete cosine transform matrices of types 1, 2, 3 and 4 have inverses of type 1, 3, 2 and 4, respectively. »
- Rows of the FourierDCTMatrix are basis sequences of the discrete cosine transform.
- The result of FourierDCTMatrix[n].list is equivalent to FourierDCT[list] when list has length n. However, the computation of FourierDCT[list] is much faster and has less numerical error. »
- For type 4, the option TargetStructure is supported, which specifies the structure of the returned matrix. Possible settings for TargetStructure include:
-
Automatic automatically choose the representation returned "Dense" represent the matrix as a dense matrix "Hermitian" represent the matrix as a Hermitian matrix "Orthogonal" represent the matrix as an orthogonal matrix "Symmetric" represent the matrix as a symmetric matrix "Unitary" represent the matrix as a unitary matrix - FourierDCTMatrix[…,TargetStructureAutomatic] is equivalent to FourierDCTMatrix[…,TargetStructure"Dense"].
- FourierDCTMatrix[…,WorkingPrecision->p] gives a matrix with entries of precision p.
Examples
open all close allScope (1)
Options (2)
TargetStructure (1)
Return the DCT matrix as a dense matrix:
FourierDCTMatrix[4, "IV", TargetStructure -> "Dense"]Return the DCT matrix as an orthogonal matrix:
FourierDCTMatrix[4, "IV", TargetStructure -> "Orthogonal"]Return the DCT matrix as a symmetric matrix:
FourierDCTMatrix[4, "IV", TargetStructure -> "Symmetric"]Applications (1)
Define 2D discrete cosine transform of size 8×8 using matrix formulation:
DCT[x_ ? MatrixQ] := Transpose[FourierDCTMatrix[8]].x.FourierDCTMatrix[8]
IDCT[x_ ? MatrixQ] := Transpose[FourierDCTMatrix[8, 3]].x.FourierDCTMatrix[8, 3]
img = [image];Simplified JPEG compression algorithm:
jpeg = ImageAssemble[Map[Image[Threshold[DCT[ImageData[#]], {"LargestValues", 8}]]&, ImagePartition[ImageSubtract[img, 0.5], 8], {2}]]Compare the original and compressed images:
GraphicsRow[{img, ImageAdd[ImageAssemble[Map[Image[IDCT[ImageData[#]]]&, ImagePartition[jpeg, 8], {2}]], 0.5]}, ImageSize -> 250]Properties & Relations (2)
A DCT matrix multiplied by a vector is equivalent to the discrete cosine transform of that vector:
data = RandomReal[1, 6];
data . FourierDCTMatrix[6] == FourierDCT[data, 2]FourierDCT is much faster than the matrix-based computation:
data = RandomReal[1, 1024];
{AbsoluteTiming[Do[FourierDCT[data], {10}];],
AbsoluteTiming[Do[FourierDCTMatrix[1024, WorkingPrecision -> MachinePrecision].data, {10}];]}A discrete cosine transform matrix of type 1 is its own inverse:
FourierDCTMatrix[4, 1]. FourierDCTMatrix[4, 1] == IdentityMatrix[4]A discrete cosine transform matrix of type 3 is an inverse of the type 2 matrix:
FourierDCTMatrix[4, 2]. FourierDCTMatrix[4, 3] == IdentityMatrix[4]A discrete cosine transform matrix of type 4 is its own inverse:
FullSimplify[FourierDCTMatrix[4, 4]. FourierDCTMatrix[4, 4]] == IdentityMatrix[4]Related Guides
Text
Wolfram Research (2012), FourierDCTMatrix, Wolfram Language function, https://reference.wolfram.com/language/ref/FourierDCTMatrix.html (updated 2024).
CMS
Wolfram Language. 2012. "FourierDCTMatrix." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2024. https://reference.wolfram.com/language/ref/FourierDCTMatrix.html.
APA
Wolfram Language. (2012). FourierDCTMatrix. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/FourierDCTMatrix.html
BibTeX
@misc{reference.wolfram_2026_fourierdctmatrix, author="Wolfram Research", title="{FourierDCTMatrix}", year="2024", howpublished="\url{https://reference.wolfram.com/language/ref/FourierDCTMatrix.html}", note=[Accessed: 12-June-2026]}
BibLaTeX
@online{reference.wolfram_2026_fourierdctmatrix, organization={Wolfram Research}, title={FourierDCTMatrix}, year={2024}, url={https://reference.wolfram.com/language/ref/FourierDCTMatrix.html}, note=[Accessed: 12-June-2026]}