Discrete Cosine Transform
The DCT is conceptually similar to the DFT, except:
The DCT does a better job of concentrating energy into lower order coefficients than does the DFT for image data.
The DCT is purely real, the DFT is complex (magnitude and phase).The DCT is purely real, the DFT is complex (magnitude and phase).
A DCT operation on a block of pixels produces coefficients that are similar to the frequency domain coefficients produced by a DFT operation. An N-point DCT has the same frequency resolution as and is closely related to a 2N-point DFT. The N frequencies of a 2N point DFT correspond to N points on the upper half of the unit circle in the complex frequency plane.
Assuming a periodic input, the magnitude of the DFT coefficients is spatially invariant (phase of the input does not matter). This is not true for the DCT.
For most images, after transformation the majority of signal energy is carried by just a few of the low order DCT coefficients. These coefficients can be more finely quantized than the higher order coefficients. Many higher order coefficients may be quantized to 0 (this allows for very efficient run-level coding).
Formulae for DCT and inverse DCT:
In the formulas, F(u,v) is the two-dimensional NxN DCT.
u,v,x,y = 0,1,2,...N-1
x,y are spatial coordinates in the sample domain.
u,v are frequency coordinates in the transform domain.
C(u), C(v) = 1/(square root (2)) for u, v = 0.
C(u), C(v) = 1 otherwise.
MPEG specifies the spatial samples to be represented in 9 bits and the coefficients to be represented in 12 bits. The dynamic range of the coefficients is specified as [-2048:+2047].
Discrete Cosine Transform