Can anyone please help me understand the 2D equation of DCT?I find it hard to understand it in terms of how to apply the equation.

For example if I have an 8x8 image and I will apply 2D-DCT to every block of that image where will I start the application from left to right, top to bottom, or after left to right, top to bottom next.???

any help would be appreciated


You don't need to split image into blocks. The DCT equation can be applied to the whole image. The block division has been chosen for JPEG standard partly because DCT was costly to compute in the past (but that's not the only reason).

You can choose any size of block (including the single block, which is the image itself), then split image into the blocks and apply DCT for every block separately.

After applying DCT on, say 8x8 block (matrix), you get another 8x8 block, but with DCT coefficients (not pixel values). You normalize them, quantize them and then encode. The coefficients in the bottom right corner of the block (I think) can be stripped off to achieve compression (the article about JPEG describes this well).

It is very similar to DFT, which uses sine and cosine bases. The DCT uses cosine bases only. The DC component is located in the top-left corner of transformed image/block and in DFT the DC component is in the middle of the image/block.

  • $\begingroup$ I'm going to use DCT for image watermarking and most of the literatures that I've read so far splits the image into 8x8. And what do you mean by "you get another 8x8 block but with DCT coefficients"?? Are you referring to the whole image block or just a block from the DCT transform image? $\endgroup$ – stbb24 May 16 '12 at 21:43
  • $\begingroup$ I meant just the transformed 8x8 block. I guess the watermarking algorithms do that to keep watermark safe under JPEG compression. $\endgroup$ – Libor May 16 '12 at 23:03
  • $\begingroup$ Note that DC = F(0,0), the DCT transformed coefficient @[0][0] (not the one after it's quantized, normalized, encoded and whatnot). $\endgroup$ – KeyC0de Feb 6 '18 at 13:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.