Documentation

idct

Inverse discrete cosine transform

Syntax

x = idct(y)
x = idct(y,n)

Description

The inverse discrete cosine transform reconstructs a sequence from its discrete cosine transform (DCT) coefficients. The idct function is the inverse of the dct function.

x = idct(y) returns the inverse discrete cosine transform of y

x(n)=k=1Nw(k)y(k)cos(π(2n1)(k1)2N),n=1,2,N

where

w(k)={1N,k=12N,2kN

and N = length(x), which is the same as length(y). 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.

x = idct(y,n) appends zeros or truncates the vector y to length n before transforming.

If y is a matrix, idct transforms its columns.

Examples

collapse all

Signal Reconstruction via Inverse Discrete Cosine Transform

Generate a signal that consists of a 25 Hz sinusoid sampled at 1000 Hz for 1 second. The sinusoid is embedded in white Gaussian noise with variance 0.01.

rng('default')

Fs = 1000;
t = 0:1/Fs:1-1/Fs;
x = sin(2*pi*25*t) + randn(size(t))/10;

Compute the discrete cosine transform of the sequence. Determine how many of the 1000 DCT coefficients are significant, that is, greater than 1.

y = dct(x);

sigcoeff = abs(y)>=1;

howmany = sum(sigcoeff)
howmany =

    17

Reconstruct the signal using only the significant components.

y(~sigcoeff) = 0;

z = idct(y);

Plot the original and reconstructed signals.

subplot(2,1,1)
plot(t,x)
yl = ylim;
title('Original')

subplot(2,1,2)
plot(t,z)
ylim(yl)
title('Reconstructed')

Related Examples

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: Van Nostrand Reinhold, 1993.

See Also

| | |

Introduced before R2006a

Was this topic helpful?