I'm creating an implementation of the DCT Steganography algorithm in Java and I'm having a slight problem. When I embed a message into a cover-image, I am doing so by initially obtaining the DC Coefficients of that image for a particular 8*8 block and then replacing the last coefficient equal to either a 0 or 1 depending on the binary message I am embedding. Once this has been embedded into the 8x8 blocks, I then pass it through the inverse DCT to re-create my Stego-object.

However, when I pass the Stego-object through DCT and recover the last coefficient of each block, sometimes the coefficient has changed and therefore doesn't produce the correct message that I originally embedded into it.

Does anyone have know/understand why this might be happening and how I can solve it?

E.g. Embedded message = 00 0 1001000 0 0111101 0 01 1 0101100101 Recovered message = 00 1 1001000 1 0111001 1 01 0 0101100101

This only happens on some images but not all and I am not sure what's happening. My program checks to see if the last coefficient is equal to 0 before it decided to embed on it or not.

  • $\begingroup$ Is there anything in the way you are transmitting the image that might change the file in any way? $\endgroup$ Commented Mar 24, 2020 at 19:09
  • $\begingroup$ Not at all, I save the file by creating a new JPG and then put that JPG back through the same program essentially. $\endgroup$ Commented Mar 24, 2020 at 19:10
  • $\begingroup$ Most steganography tools avoid modifying the DC coefficient and the AC coefficients with zero value. The first, visually distorts the image, the second is highly detectable. $\endgroup$ Commented Mar 24, 2020 at 19:39

1 Answer 1


The inverse DCT is used to decompress the image, but you do not have to decompress the image. If you decompress the image, I suppose that you also compress it again for reading the DCT coefficients, and as far as JPEG is a lossy format, some DCT coefficients could change their value.

But JPEG does not work in this way. In JPEG the DCT coefficients are compressed and saved into the file. It is the visualization tool that decompresses the image to show it to the user.

  • $\begingroup$ Yes, this makes sense. Thank you for clearing that up! $\endgroup$ Commented Mar 25, 2020 at 23:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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