Documentation

idct

Inverse discrete cosine transform

Description

example

x= idct(y)returns the inverse discrete cosine transform of input arrayy. The outputxhas the same size asy. Ifyhas more than one dimension, thenidctoperates along the first array dimension with size greater than 1.

x= idct(y,n)zero-pads or truncates the relevant dimension ofyto lengthnbefore transforming.

x= idct(y,n,dim)computes the transform along dimensiondim. To input a dimension and use the default value ofn, specify the second argument as empty,[].

example

y= idct(___,'Type',dcttype)specifies the type of inverse discrete cosine transform to compute. SeeInverse Discrete Cosine Transformfor details. This option can be combined with any of the previous syntaxes.

例子

collapse all

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. Choose 1 as the threshold for significance.

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')

Verify that the different variants of the discrete cosine transform are orthogonal, using a random signal as a benchmark.

Start by generating the signal.

s = randn(1000,1);

Verify that DCT-1 and DCT-4 are their own inverses.

dct1 = dct(s,'Type',1); idt1 = idct(s,'Type',1); max(abs(dct1-idt1))
ans = 1.3323e-15
dct4 = dct(s,'Type',4); idt4 = idct(s,'Type',4); max(abs(dct4-idt4))
ans = 1.3323e-15

Verify that DCT-2 and DCT-3 are inverses of each other.

dct2 = dct(s,'Type',2); idt2 = idct(s,'Type',3); max(abs(dct2-idt2))
ans = 4.4409e-16
dct3 = dct(s,'Type',3); idt3 = idct(s,'Type',2); max(abs(dct3-idt3))
ans = 1.1102e-15

Input Arguments

collapse all

Input discrete cosine transform, specified as a real-valued or complex-valued vector, matrix, N-D array, orgpuArrayobject.

SeeRun MATLAB Functions on a GPU(Parallel Computing Toolbox) andGPU Support by Release(Parallel Computing Toolbox) for details ongpuArrayobjects.

Example:dct(sin(2*pi*(0:255)/4))specifies the discrete cosine transform of a sinusoid.

Example:dct(sin(2*pi*[0.1;0.3]*(0:39))')specifies the discrete cosine transform of a two-channel sinusoid.

Data Types:single|double
Complex Number Support:Yes

Inverse transform length, specified as a positive integer scalar.

Data Types:single|double

Dimension to operate along, specified as a positive integer scalar.

Data Types:single|double

Inverse discrete cosine transform type, specified as a positive integer scalar from 1 to 4.

Data Types:single|double

Output Arguments

collapse all

Inverse discrete cosine transform, returned as a real-valued or complex-valued vector, matrix, N-D array, orgpuArrayobject.

More About

collapse all

Inverse Discrete Cosine Transform

The inverse discrete cosine transform reconstructs a sequence from its discrete cosine transform (DCT) coefficients. Theidctfunction is the inverse of thedctfunction.

The DCT has four standard variants. For a transformed signalyof lengthN, and withδkℓthe Kronecker delta, the inverses are defined by:

  • Inverse of DCT-1:

    x ( n ) = 2 N 1 k = 1 N y ( k ) 1 1 + δ k 1 + δ k N 1 1 + δ n 1 + δ n N cos ( π N 1 ( k 1 ) ( n 1 ) )

  • Inverse of DCT-2:

    x ( n ) = 2 N k = 1 N y ( k ) 1 1 + δ k 1 cos ( π 2 N ( k 1 ) ( 2 n 1 ) )

  • Inverse of DCT-3:

    x ( n ) = 2 N k = 1 N y ( k ) 1 1 + δ n 1 cos ( π 2 N ( 2 k 1 ) ( n 1 ) )

  • Inverse of DCT-4:

    x ( n ) = 2 N k = 1 N y ( k ) cos ( π 4 N ( 2 k 1 ) ( 2 n 1 ) )

The series are indexed fromn= 1andk= 1instead of the usualn= 0andk= 0, because MATLAB®vectors run from 1 toNinstead of from 0 toN– 1.

All variants of the DCT areunitary(or, equivalently,orthogonal): To find the forward transforms, switchkandnin each definition. In particular, DCT-1 and DCT-4 are their own inverses, and DCT-2 and DCT-3 are inverses of each other.

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.

[3] Oppenheim, Alan V., Ronald W. Schafer, and John R. Buck.Discrete-Time Signal Processing. 2nd Ed. Upper Saddle River, NJ: Prentice Hall, 1999.

Extended Capabilities

Introduced before R2006a