Discrete cosine transform (DCT)

`y = dct(x)`

y = dct(x,n)

y = dct(gpuArrayX,n)

`y = dct(x)`

returns the unitary
discrete cosine transform of `x`

. `y`

has
the same size as `x`

. If `x`

is
a matrix, then `dct`

transforms its columns.

`y = dct(x,n)`

zero-pads or
truncates `x`

to length `n`

before
transforming.

`y = dct(gpuArrayX,n)`

returns the discrete
cosine transform of `gpuArray`

object `gpuArrayX`

.
See GPU Computing and GPU
System Requirements for details on `gpuArray`

objects.

The discrete cosine transform (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.

The DCT is defined by

$$y(k)=w(k){\displaystyle \sum _{n=1}^{N}x}(n)\mathrm{cos}\left(\frac{\pi}{2N}(2n-1)(k-1)\right),\text{\hspace{1em}}k=1,2,\dots ,N,$$

where

$$w(k)=\{\begin{array}{ll}\frac{1}{\sqrt{N}},\hfill & k=1,\hfill \\ \sqrt{\frac{2}{N}},\hfill & 2\le k\le N,\hfill \end{array}$$

and *N* is the length of `x`

.
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.

[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.

Was this topic helpful?