Uploaded by mma

Discrete Cosine Transforms

advertisement
Discrete Cosine Transforms
The discrete cosine transform (DCT) is another frequently used transform in image processing. An advantage of DCT
over DFT is that DCT does not involve complex computations. The equations for DCT and inverse DCT are shown
below:
NAME
dct2 - performs 2D-DCT of an input image and returns the transformed image to the user.
SYNOPSIS
dct2(input_file_name)
dct2(input_file_name, [mrows, ncols])
dct2(input_file_name, mrows, ncols)
mrows --pads or crops the image to mrowsXncols before transformation
ncols
--pads or crops the image to mrowsXncols before transformation
DESCRIPTION
dct2 performs 2D-DCT on an input image. It reads the image from the input file, pads or crops the image if necessary,
and performs the 2D-DCT transformation. The output of the 2D-DCT transformation is a real matrix, which is returned
to the user. The transformed image is also displayed on the screen.
This implementation of dct2 makes use of the "dct" function provided by MATLAB. "dct" is first applied to the rows of
the image; after that, "dct" is again applied to the columns of the row-transformed image.
EXAMPLES
lena_dct2=dct2('LENA.TIF')
This example performs 2D-DCT of LENA and stores the transform of the image in the variable "lena_dct2" (Figure
6.1a).
ptr_dct2=dct2('PAINTER.TIF')
This example performs 2D-DCT of PAINTER and stores the transform of the image in the variable "ptr_dct2" (Figure
6.1b).
a. 2D-DCT of LENA
b. 2D-DCT of PAINTER
Figure 6.1 Examples of 2D-DCT transformed images
NAME
idct2 - performs inverse 2D-DCT on an input array.
SYNOPSIS
idct2(x, output_file_name)
idct2(x, output_file_name, [mrows, ncols])
idct2(x, output_file_name, mrows, ncols)
x
-- the matrix representation of a DCT transformed image
mrows -- pads or crops the image to mrowsXncols before transforming
ncols
-- pads or crops the image to mrowsXncols before transforming
DESCRIPTION
idct2 performs 2D-IDCT on a DCT transformed input image. x, which is a real matrix, is the DCT-transformed image.
idct2 reads an image matrix, crops the image if necessary before transformation, and performs the inverse
transformation. The output of the idct2 function is written to the output file. The format of the output image is TIFF.
This implementation of idct2 makes use of the "idct" function provided by MATLAB. idct is first applied to the rows of
the image; after that, idct is again applied to the columns of the row-transformed image
EXAMPLES
idct2(lena_dct2, 'id_lena.tif')
This example performs 2D-IDCT of the previously 2D-DCT transformed LENA (Figure 6.2a).
idct2(ptr_dct2, 'id_ptr.tif')
This example performs 2D-IDCT of the previously 2D-DCT transformed PAINTER (Figure 6.2b).
a. Restored LENA via 2D-IDCT
b. Restored PAINTER via 2D-IDCT
Figure 6.2 Examples of 2D-IDCT transformed images
Download