Search code examples
compressionjpegfftdct

0th Component of the Discrete Cosine Transform (DCT) is NOT the mean?


I'm finding this again and again in articles related to the DCT, where people claim that the 0th coefficient of the DCT matrix is the average or mean of the values being transformed.

For example, see here, here, or even in the JPEG Bible here.

However, this simply isn't true... If the formula for the DCT-II is

enter image description here

(this formula from Matlab) where it turns out the coefficients outside the sums end up being 1/8. In no way does this end up being the mean. Rather, it's the sum divided by 8. To be the mean, there would have to be another 1/8 term. I can't understand why this is so, can somebody explain it?


Solution

  • In your link to the MATLAB documentation, it shows that the two α values are 1/sqrt(M) and 1/sqrt(N). This is one convention. Wikipedia shows DCT-II without any normalization (α) terms at all.

    Basically, for the inverse DCT of the forward DCT of an image I to be equal to I, some normalization is necessary somewhere. Some authors put it in the forward transform, some put it in the inverse transform, and some split it and put it in both. It seems MATLAB follows this latter convention.

    So, depending on which normalization is used, the DC term (0th coefficient) is the mean, the sum, or something half-way.

    The same is true for the Fourier transform. The common normalization is 1/N in the inverse transform, but sometimes you'll see a normalization of 1/sqrt(N) in both the forward and backward transform, or a normalization of 1/N only in the forward transform.