Discrete cosine transform matrix
Calculate Discrete Cosine Transform Matrix
Read an image into the workspace and cast it to class
A = im2double(imread('rice.png')); imshow(A)
Calculate the discrete cosine transform matrix.
D = dctmtx(size(A,1));
Multiply the input image
D to get the DCT of the columns of
A, and by
D' to get the inverse DCT of the columns of
dct = D*A*D'; imshow(dct)
n — Size of DCT matrix
Size of DCT matrix, specified as a positive integer.
The two-dimensional DCT of
Acan 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
Dneeds 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
D, and then calculate each DCT using
Ais each 8-by-8 block). This is faster than calling
dct2for each individual block.
Introduced before R2006a