# validation of a pseudo jpeg compression

I've done something which is not exactly the jpeg algorithm. What I've done is that given an image $I$ of $N\times N$ size, I have computed the DCT of individual $8\times 8$ blocks.

Once this has been done, I have imposed that the top leftmost corner is left intact but the other elements be equalled to zero.

Then i compute the inverse-DCT on that block and use it to reconstruct my image.

The algorithm seems to work giving the following results  Given that I've ignored lots of steps in the jpeg algorithm (all the things related to huffman encoding, quantization matrix etc) why is this simple algorithm working?

Thanks.

• Transform coding is the same (DCT). Then you apply a coarse quantization (all but dc terms equal to zero). From here, all JPEG does is only to encode the quantized coefficients (represent the coefficients with a number of bits as small as possible) by applying run length coding, differential coding, and hufman/arithmatic coding on the quantized coefficients. Also note that the dc term has the highest information (which is not quarantized here). That's why a quite sensible picture is reconstructed.
– msm
Sep 30, 2016 at 2:16
• Happy new year, and a reminder that your question and its answers require some action (votes, acceptance) Dec 31, 2016 at 16:17
If you compute a $8\times 8$ 2D-DCT, and keep the top left corner only, you are keeping a quantity that is proportional to the average of each $8\times 8$ block. This is the DC component, similar to the $0$ frequency in a Fourier transform. This works like a JPEG coding with a quantization table looking like:
$$\displaystyle \left( \begin{array}{cccc} 1 & \infty & \cdots & \infty\\ \infty & \infty & \cdots & \infty\\ \vdots & \vdots & \ddots & \infty\\ \infty & \infty & \cdots & \infty \end{array}\right)$$
Performing the inverse DCT with this "kind of" quantization spreads the average value over the $8\times 8$ block. What you are doing is equivalent to performing a moving average with an $8\times 8$ uniform window and then downsampling by $8$ in both the $x$ and $y$ directions. You compress by replacing each $64$-pixel block by its average, resulting (effectively) in a $64$ times smaller image, and you "fake" an original size image by extrapolating the average.
However, you cannot claim a $1/64$ compression yet, because the coefficients you keep are not quantized yet, and are stored for instance on $32$-bit floating point words. Before you go into more advanced coding, you are about at a $1/16 = 1/64\times 32/8$ compression rate.