Saturday, February 1, 2020

matlab - 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?



Answer



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.


DCT distribution


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.)


No comments:

Post a Comment

digital communications - Understanding the Matched Filter

I have a question about matched filtering. Does the matched filter maximise the SNR at the moment of decision only? As far as I understand, ...