D = dctmtx(n) returns the n-by-n DCT (discrete cosine transform) matrix. D*A is the DCT
of the columns of A and D'*A is the inverse DCT of the columns of A (when A is n-by-n). If A is square,
the two-dimensional DCT of A can be computed as D*A*D'. This computation is sometimes
faster than using dct2, especially if you are computing a large number of small DCTs,
because D needs to be determined only once. For example, in JPEG compression,
the DCT of each 8-by-8 block is computed. To perform this computation, use dctmtx
to determine D, and then calculate each DCT using D*A*D' (where A is each 8-by-8 block).
This is faster than calling dct2 for each individual block. We have developed a simple code
to generalize the DCT and IDCT for arbitrary NxM images.
Download source code
Requirements: Matlab,
Matlab Image Processing Toolbox.