# DCT and mean difference of an image

If we subtract the mean of image from the DCT coefficients of an image

• what does it signifies?
• and what type of distribution does it follow?

Example in MATLAB:

i=imread('cameraman.tif');
c=mean2(i);
d=dct2(i);
f=c-d;


what does f signifies?

Following the answer given by @msm, linear transformations applied on images often have a DC (direct current) component, i.e. a coefficient that is proportional to the mean of the image. It amounts to projecting the image onto a constant vector (e.g. here on a constant image).

The scale factor depends on the image size only, and depends on the normalization applied to the constant vector. As said by @msm, in the case of an orthonormal transform such as the dct2, the proportional factor is exactly the square-root of the number of elements (or pixels) of the image, hence $\sqrt{n_x\times n_y}$.

Subtracting the average from the scaled dct2 coefficients does not seem useful, from what I know.

However, the question can be reframed. Whether you transform the whole matrix or little blocks, the DC coefficients have, in practice on natural images, specific distributions. On the other coefficients, called AC (alternating current), several works have proposed a possible fit by parametric distributions, like Laplace, Gauss or Rayleigh laws. The generalized Gaussian, or Laplacian-Gaussian law seems a good fit on natural images, as detailed for instance in Distribution shape of two-dimensional DCT coefficients of natural images, 1993 or On the Modeling of DCT and Subband Image Data for Compression, 1995. The image below is the average distribution of the absolute values of coefficients on $8\times 8$ blocks from the cameraman image ($\log$ scale). You can see the different behavior of the $d(1,1)$ coefficient. This is why, in these applications, the mean is removed from the image BEFORE the DCT. Or the DC coefficient is removed from the DCT transform.

When either performed globally, or locally, the parameters obtained from the fit can be used to improve compression performance, or infer a class for block (texture, edge, etc.)

You can investigate that if the size of the DCT block (which is the whole image in here) is $x\times y$, then

c=d(1,1)/sqrt(x*y);


That is, the DC element of the DCT matrix (i.e. d(1,1)) is actually the mean of the image scaled by $\sqrt{xy}$.

So you are basically subtracting a scaled version of the DC component form all coefficients, which makes not much sense at the moment, except if you provide more context.

• just want to know this "subtracting a scaled version of the DC component form all coefficients"is a better fit for generalized Gaussian distribution rather than DCT coefficients itself...for natural images .This operation has particular effect on DC component as@Laurent Duval shows in graph of cameraman the DC coefficient misbehavior to the distribution. – usman Dec 8 '16 at 6:15
• This is very wrong. But never mind... – msm Dec 8 '16 at 6:45