- Home
About PCS

IP cores

Education

- Contact Us

The Discrete Cosine Transform is a linear transform, which maps an n-dimensional vector to set of n coefficients. A linear combination of n known basis vectors weighted with the n coefficients will result in the original vector. The known basis vectors of transforms from this class are “sinusoidal“, which means that they can be represented by sinus shaped waves or, in other words, they are strongly localized in the frequency spectrum. Therefore one speaks about transformation to the frequency domain. The most popular member of this class is the Discrete Fourier Transformation (DFT).The difference between DCT and DFT is that DFT applies to complex numbers, while DCT uses just real numbers. For real input data with even symmetry DCT and DFT are equivalent.

In JPEG compression the input data are two-dimenssional, presented in 8x8 blocks. There's a need of using two-dimenssional DCT. Since each dimension can be handled separately, the two-dimensional DCT follows straightforward form the one-dimensional DCT. A one-dimensional DCT is performed along the rows and then along the columns, or vice versa.

The formula used for one-dimensional DCT:

The formula used for two-dimensional DCT:

Applying these formulas directly requires much computational resources therefore an implementation in hardware can be very efficient.

The figure below, shows example of 8x8 block before DCT.

75 | 76 | 75 | 75 | 69 | 66 | 77 | 71 |

73 | 74 | 73 | 74 | 63 | 64 | 68 | 69 |

69 | 68 | 71 | 72 | 67 | 58 | 48 | 41 |

59 | 55 | 56 | 52 | 47 | 40 | 24 | 9 |

51 | 50 | 45 | 41 | 33 | 22 | 7 | -5 |

43 | 37 | 32 | 24 | 15 | 5 | -6 | -25 |

29 | 21 | 9 | -2 | -10 | -21 | -44 | -69 |

9 | -4 | -17 | -35 | -52 | -61 | -57 | -35 |

After Discrete Cosine Transform the block has following values:

251 | 118 | -13 | 6 | -2 | 6 | -1 | 0 |

279 | -68 | -8 | -7 | -1 | 4 | -4 | -1 |

-51 | -14 | 34 | -14 | 5 | 0 | -1 | 0 |

27 | 5 | -10 | 8 | -7 | 4 | -5 | 1 |

-22 | -7 | 14 | -9 | 4 | -2 | 1 | 1 |

-3 | 15 | -18 | 15 | -6 | 2 | -1 | 2 |

7 | -9 | 6 | -6 | 4 | 0 | 0 | 2 |

3 | 7 | -9 | 3 | 0 | -2 | -1 | 0 |

As it can be seen higher values of transform coefficients are concentrated on the top left corner. In the frequency domain it looks like low frequency has advantage over high frequency. It is shown on the figure below.

As you can see only small amount of low frequency elements dominates over the rest of the coefficients. It allows to reduce data during next stages of JPEG compression.