dctn
N-dimensional Discrete Cosine Transform
Contents
Download
Syntax
Y = dctn(X)
Description
Y = dctn(X) returns the discrete cosine transform of X. X can be a vector, a matrix or a multi-dimensional array. The array Y is the same size as X and contains the discrete cosine transform coefficients. This transform can be inverted using idctn.
Notes: The returned array is of class double. For vectors and matrices, dctn(X) is similar to dct(X) and dct2(X) within round-off errors. dct and dct2 are included in the Signal and Image Processing Toolboxes. No toolbox is required for dctn.
Example
Perform the discrete cosine transform (DCT) of an image using dctn and display the resulting coefficients.
RGB = imread('autumn.tif'); I = rgb2gray(RGB); imshow(I) % original gray-scaled image
J = dctn(I); % discrete cosine transform
imshow(log(abs(J)),[])
The commands below set values less than magnitude 10 in the DCT matrix to zero, then recover the image using the inverse DCT. DCT can be used as an image compressor.
J(abs(J)<10) = 0; % lossy compression K = idctn(J); % inverse DCT imshow(K,[0 255])
Reference & Information
Narasimha M. et al, On the computation of the discrete cosine transform, IEEE Trans Comm, 26, 6, 1978, pp 934-936.
Discrete Cosine Transform on Wikipedia.
See also
About the author
Damien Garcia, Eng., Ph.D. Assistant professor, Department of radiology CRCHUM, University of Montreal Hospital Montreal, QC, Canada Damien.Garcia.REMOVE-THIS@BiomeCardio.com