Just a quick question about DCT Steganography. Do you embed the data before or after you send the 8*8 block through the quantization table?


2 Answers 2


The quantization table is part of the compression or decompression stage in JPEG, but for using steganography you should not compress/decompress the image, because these operations modify the DCT coefficients.

The usual process to hide a message in JPEG files is:

  1. Read DCT coefficients from the JPEG file.
  2. Modify the DCT coefficients to hide the message.
  3. Write the DCT coefficients into the JPEG file.

So, the compression needs to be done before you hide the message. And if you decompress and compress the image again you could destroy the message.


JPEG contains quantized DCT coefficients $Y_{quantized}$. By "sending a block through the quantization table", you probably mean dequantization, multiplication of each DCT block with the corresponding quantization table $q$.

$$Y_{dequantized}=Y_{quantized}\cdot q$$

To complete Daniel Lerch's answer, you embed into quantized DCT coefficients. You can read them from JPEG for example using libjpeg library.

Problem with embedding into unquantized coefficients is the quantization, which is one of the lossy operations during the JPEG compression.


In addition, you can't get dequantized coefficients directly from libjpeg, because dequantization is already in the lossy part of the JPEG compression. But you can easily compute them yourself, if you want.

Example: embedding into quantized vs. unquantized DCT coefficient

Let's say you have an unquantized DCT coefficient $Y_{unquantized} = 42$ and a quantization value $q=9$. You quantize the coefficient as follows (quantization done by rounding).

$$Y_{quantized} = Q\bigg(\frac{42}{9}\bigg)\stackrel{Q=round}{=}5$$

This is the value stored inside JPEG. Embedding into the quantized coefficients is the way to go. Let's say embedding change means adding one.


If you would instead embed into the dequantized coefficient, your value would change if you quantize again.

$$Y_{dequantized}=5\cdot9=45$$ $$Y_{dequantized}^{with~stego}=Y_{dequantized}+1=46$$ $$Y_{quantized~again}=Q\bigg(\frac{46}{9}\bigg)\stackrel{Q=round}{=}5$$ $$Y_{dequantized~again}=5\cdot9=45$$

Quantization changed the value of the unquantized coefficient, ergo, you can't read your message anymore.


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.