# DCT - Coefficients and Basis Function

I am trying to understand how the Discrete Cosine Transformation works but I am not sure if I am at the right road.

Assuming that I have an $$8\times8$$ pixels image and I am applying the DCT to this sample. What I will get as a result is a $$8\times8$$ matrix of the DCT Coefficients.

In order to convert from this to the original image I will need to multiply each DCT Coefficient with its corresponding basis function and sum the result. But how do I calculate the basis function if DCT only returns the coefficients?

When DCT is defined by a matrix, then this matrix contains the necessary information to build the basis functions.

Suppose that $$I$$ is your $$8\times8$$ block, and $$D$$ a real $$8\times8$$ matrix for a 1D DCT (with column-wise vectors). Then $$D^TI$$ applies the DCT on columns, and $$ID$$ does it on rows. Thus, a 2D DCT yields a $$8\times8$$ matrix $$C$$ of coefficients defined by:

$$C = D^T I D\,.$$

Consequently, we have $$I = D C D^T \,.$$

If we call $$\Gamma_{m,n}$$ the matrix such that every element is zero, except for $$\Gamma[m,n]=1$$ (the canonical basis), then

$$C = \sum_{m,n} C[m,n]\Gamma_{m,n}$$

hence, by linearity:

$$I = \sum_{m,n} C[m,n] D \Gamma_{m,n} D^T \,.$$

Each matrix $$D \Gamma_{m,n} D^T$$ is an element of the basis you are looking for.