Wednesday, June 15, 2016

2D-DCT Part 1


The forward 2D-DCT is computed from the following equation:








In the previous equation N is the block size, in our situation our block size is 8x8 so N=8, x(i, j) is the input sample and X(m,n) is the dct transformed matrix.

A straightforward implementation of the previous equation requires N4 multiplications. However, the DCT is a separable transform and it can be expressed in matrix notation (the row-column decomposition) as two 1D-DCT as follows:
Z=A*X*AT
The matrix A is a NxN (8x8) matrix whose basis vectors are sampled cosines defined as:
Each NxN (8x8) matrix-matrix multiply is separated into N (8) matrix-vector products. A standard block diagram of a 2D-DCT processor with the use of 1D-DCT units is shown in the following figure:

The first unit computes the Y = A*X and the second computes the Z= Y*AT. Each 1D-DCT unit must be capable of computing N multiplies per input sample.

The first 1D-DCT unit operates on rows of A and columns of  X. However, in each cycle we have the values of the elements in each row instead of the elements in each columns. So it is wiser to compute first the product Y = A * XT. Thus, in the second stage we have to perform 1D-DCT in order to compute the product Z = A*YT. It is obvious that Z = A * (A * XT)equals to Z = A * X * AT

I created a simple code in python to confirm that the matrices multiplications equals to the final 2D-DCT. I confirmed the results of the row-column decomposition approach with the results of the intergrated matlab dct() function using a test block. 

In the next part, I will describe in details my implementation of the 2D-DCT in MyHDL.

All the above pictures and equations were taken from the paper "A 100 mhz 2-d 8x8 DCT/IDCT Processor for HDTV Applications" link.



4 comments:

  1. Really good information! Good use of prototype and experimentation!

    Do you have a reference for the information presented in this post? You should include references.

    ReplyDelete
  2. Really good information! Good use of prototype and experimentation!

    Do you have a reference for the information presented in this post? You should include references.

    ReplyDelete
  3. Yes I have a reference. I will include it in my post.

    ReplyDelete
  4. http://ieeexplore.ieee.org/xpl/login.jsp?tp=&arnumber=388064&url=http%3A%2F%2Fieeexplore.ieee.org%2Fiel4%2F76%2F8802%2F00388064.pdf%3Farnumber%3D388064

    ReplyDelete