Is it possible to determine the resulting pixel values and modify them before the compressed jpeg image is actually created?

For example, I'm at the stage where I already have the quantized DCT coefficients of the original image and I want to change all pixels of the resulting image with a (255, 255, 0) value to (255, 254, 0).

What I was thinking is, if this is possible I would need to:

  1. Get the equivalent DCT coefficient of original image and do quantization
  2. Determine the resulting pixel values and do desired changes
  3. Obtain the new DCT coefficients that will result to it
  4. Proceed to Huffman encoding

Can the following be done during Huffman encoding?

  1. Get the equivalent DCT coefficient from YCbCr and do quantizations
  2. Do Huffman encoding and modify the desired pixel
  • $\begingroup$ In your example you show a color of (255, 255, 0) but each DCT block will correspond to a different part of the color. You would have three blocks of DCT coefficients to work with in this case. Also, are your colors in RGB colorspace? If so, JPEG is typically in the Y'CbCr colorspace and you'll have to convert between the two as well. $\endgroup$ Feb 7, 2012 at 19:38
  • $\begingroup$ The only method I've heard of is trial and error, which can, and may need to done on a macroblock basis. Compress, decompress, compare against the desired result, then vary the input macroblock, including pixels other than the target, and try again. $\endgroup$
    – hotpaw2
    Feb 8, 2012 at 2:44

1 Answer 1


To give you an upfront answer your question you want to determine the $pixel-values$ from $DCT-Coefficients$ probably there is nothing on earth better than doing IDCT itself!

However, leaving aside some vagueness i can re-phrase your question:

If i have an algorithm x - that is defined to work on Pixels, here is what i do:
DCT-Coeffs -> IDCT -> pixels Algorithm_X -> pixels DCT -> DCT-Coeffs
(ignoring other stuff that is peripheral).

The question is: is there a short cut to this brute force where i am obviously undoing quite some stuff done in first stage?

What you are referring to is what is generally known as Compressed Domain Processing.

DCT-Coeffs -> Compressed_Domain_Algorithm_X -> DCT-Coeffs

Basically, all compressed domain algorithm exploits the linearity of DCT. For example

$$ Y = \alpha * X_1 + \beta * X_2 $$ then,
$$ DCT(Y) = \alpha * DCT(X_1) + \beta * DCT(X_2) $$ where $\alpha$ $\beta$ are scalars.

There are many things possible, and while many NOT. It is too vast to answer the set of all compressed domain algorithms which are possible, but i would recommend key readings that will set a great stage for you.

  1. Compressed Domain Processing of JPEG-encoded images by Brian C. Smith , Lawrence A. Rowe Real-Time Imaging (1996)

  2. A Survey of Compressed Domain Processing Techniques by Brian C. Smith Proc. NSF Workshop on Reconnecting Science

  3. Algorithms for Manipulating Compressed Images, Brian C. Smith, Lawrence A. Rowe, IEEE Computer Graphics and Applications, Sept. 1993, vol.13, (no.5):34-42.

  4. Manipulation and compositing of MC-DCT compressed video by Shih-Fu Chang, David G. Messerschmitt IEEE Journal on Selected Areas in Communications, 1995/1, Volume 13 Issue 1

  5. Compressed-Domain Video Processing by Susie Wee, Bo Shen, John Apostolopoulo HP Labs Tech Report 2002.

Specifics: If you are using libjpeg you can actually get quantized DCT co-efficients directly. However, most above literature refers un-quantized DCT co-efficients.


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.