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.

To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

2-D discrete cosine transform

`B = dct2(A)`

B = dct2(A,m,n)

B = dct2(A,[m n])

`B = dct2(A)`

returns the two-dimensional
discrete cosine transform of `A`

. The matrix `B`

is
the same size as `A`

and contains the discrete cosine
transform coefficients *B(k*_{1}*,k*_{2}*).*

`B = dct2(A,m,n)`

pads the
matrix `A`

with 0's to size `m`

-by-`n`

before
transforming. If `m`

or `n`

is smaller
than the corresponding dimension of `A`

, `dct2`

truncates `A`

.

`B = dct2(A,[m n])`

same as
above.

`A`

can be numeric or logical. The returned
matrix `B`

is of class `double`

.

The commands below compute the discrete cosine transform for
the `autumn`

image. Notice that most of the energy
is in the upper left corner.

RGB = imread('autumn.tif'); I = rgb2gray(RGB); J = dct2(I); imshow(log(abs(J)),[]), colormap(gca,jet(64)), colorbar

Now set values less than magnitude 10 in the DCT matrix to zero,
and then reconstruct the image using the inverse DCT function `idct2`

.

J(abs(J) < 10) = 0; K = idct2(J); imshow(I) figure, imshow(K,[0 255])

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

[2] Pennebaker, William B., and Joan L. Mitchell, *JPEG:
Still Image Data Compression Standard,* Van Nostrand Reinhold,
1993.

Was this topic helpful?