This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English verison of the page.

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.


2-D inverse discrete cosine transform


B = idct2(A)
B = idct2(A,m,n)
B = idct2(A,[m n])


B = idct2(A) returns the two-dimensional inverse discrete cosine transform (DCT) of A.

B = idct2(A,m,n) pads A with 0's to size m-by-n before transforming. If [m n] < size(A), idct2 crops A before transforming.

B = idct2(A,[m n]) same as above.

For any A, idct2(dct2(A)) equals A to within roundoff error.

Class Support

The input matrix A can be of class double or of any numeric class. The output matrix B is of class double.


collapse all

This example shows how to remove high frequencies from an image using the two-dimensional discrete cosine transfer (DCT).

Read an image into the workspace, then convert the image to grayscale.

RGB = imread('autumn.tif');
I = rgb2gray(RGB);

Perform a 2-D DCT of the grayscale image using the dct2 function.

J = dct2(I);

Display the transformed image using a logarithmic scale. Notice that most of the energy is in the upper left corner.


Set values less than magnitude 10 in the DCT matrix to zero.

J(abs(J) < 10) = 0;

Reconstruct the image using the inverse DCT function idct2.

K = idct2(J);

Display the original grayscale image alongside the processed image.

title('Original Grayscale Image (Left) and Processed Image (Right)');


idct2 computes the two-dimensional inverse DCT using:

Amn=p=0M1q=0N1αpαqBpqcosπ(2m+1)p2Mcosπ(2n+1)q2N, 0mM10nN1,


αp={1M, p=0             2M, 1pM1


αq={1N, q=0            2N, 1qN1.


[1] Jain, A. K., Fundamentals of Digital Image Processing, Englewood Cliffs, NJ, Prentice Hall, 1989, pp. 150-153.

[2] Pennebaker, W. B., and J. L. Mitchell, JPEG: Still Image Data Compression Standard, New York, Van Nostrand Reinhold, 1993.

See Also

| | |

Introduced before R2006a

Was this topic helpful?