| Signal Processing Toolbox | Search  Help Desk |
| dct | Examples See Also |
Discrete cosine transform (DCT).
Syntax
y = dct(x) y = dct(x,n)
Description
y = dct(x)
returns the unitary discrete cosine transform of x
x, and x and y are the same size. If x is a matrix, dct transforms its columns. The series is indexed from n = 1 and k = 1 instead of the usual n = 0 and k = 0 because MATLAB vectors run from 1 to N instead of from 0 to N- 1.
y = dct(x,n)
pads or truncates x to length n before transforming.
The DCT is closely related to the discrete Fourier transform. You can often reconstruct a sequence very accurately from only a few DCT coefficients, a useful property for applications requiring data reduction.
Example
Find how many DCT coefficients represent 99% of the energy in a sequence:x = (1:100) + 50*cos((1:100)*2*pi/40); X = dct(x); [XX,ind] = sort(abs(X)); ind = fliplr(ind); i = 1; while (norm([X(ind(1:i)) zeros(1,100-i)])/norm(X)<.99) i = i + 1; end i = 3
See Also
fft |
One-dimensional fast Fourier transform. |
idct |
Inverse discrete cosine transform. |
dct2 |
Two-dimensional DCT (see Image Processing Toolbox User's Guide). |
idct2 |
Two-dimensional inverse DCT (see Image Processing Toolbox User's Guide). |
References
[1] Jain, A.K. Fundamentals of Digital Image Processing. Englewood Cliffs, NJ: Prentice-Hall, 1989. [2] Pennebaker, W.B., and J.L. Mitchell. JPEG Still Image Data Compression Standard. New York, NY: Van Nostrand Reinhold, 1993. Chapter 4.