5. How does this work on two dimensional data ?

If the data is also a 4x4 matrix, then we apply the DCT transform to each row and each column.  Doing the columns is just mutiplying the whole matrix by the DCT matrix.  To do the rows, we turn them into columns by transposing the matrix.

Here are two functions that perform the forward and backward transform on two dimensional data.

twoDimDct[data_] := Transpose[ dct . Transpose[ dct . data ]] ;

invTwoDimDct[dctData_] := Transpose[idct . Transpose[idct . dctData]] ;

And here's an example of the transform of a four by four block of ones.  The result is nearly zero everywhere but in the top left.

RowBox[{RowBox[{ones,  , =,  , RowBox[{{, RowBox[{1., ,, 1., ,, 1., ,, 1.}], }}]}], ;}] onesMap = {ones, ones, ones, ones} ; onesMap//MatrixForm

( 1.`   1.`   1.`   1.` )            1.`   1.`   1.`   1.`            1.`   1.`   1.`   1.`            1.`   1.`   1.`   1.`

twoDimDct[onesMap]//MatrixForm

( 16.`                        4.440892098500626`*^-16     0.`                          ... 344752192`*^-15   1.232595164407831`*^-32     2.465190328815662`*^-32     1.3250398017384183`*^-31

invTwoDimDct[twoDimDct[onesMap]]//MatrixForm

( 0.9999999999999998`   1.`                   0.9999999999999997`   1.`                ... 9999999999999999`            0.9999999999999999`   1.0000000000000002`   0.9999999999999998`   1.`


Created by Mathematica  (April 1, 2004)