Can this tool be used to examine or modify the quantization table?

Started by Archive, May 12, 2010, 08:54:28 AM

Previous topic - Next topic

Archive

[Originally posted by billo on 2008-11-20 20:40:38-08]

Can this tool look at/change the quantization table (DQT segment) or Huffman (DHT)?  In looking over the documentation, I didn't see it.

Thanks!

billo

Archive

[Originally posted by billo on 2008-11-20 20:42:02-08]

Sorry, I should have added "... in JPEG files..."

billo

Archive

[Originally posted by exiftool on 2008-11-20 23:52:30-08]

For what purpose?

You can view the DQT and DHT segments with the -v3 or
-v4 options.  The only valid way to change this data is
to recompress the image with a different set of tables, which
is beyond the scope of exiftool.

- Phil

Archive

[Originally posted by billo on 2008-11-21 02:38:29-08]

Thanks for the response.  

"For what purpose?"

There are two primary purposes.  There are three primary purposes.  One has to do with image quality.  The second has to do with security.

The image quality one is more iffy, but theoretically an interesting issue.  Certainly you can change image quality by going into the firmware of a camera and modifying the quantization tables during image acquisition.  There have been a number of firmware hacks for various cameras that do exactly that -- tweak the quantization table for a given quality menu level.  Theoretically, you could play a little with it by tweaking it in the image as well -- though of course any of the DCT coefficients that are gone are still gone.

The two security issues are not as iffy.  

First, there is the issue of obscuring image manipulation.  Let's say you take an image with a camera that has a proprietary quantization table.  If you modify the image in Adobe Photoshop and save it, it will have the Adobe DQT and DHT data.  It is thus possible to determine that the image has been manipulated just by looking at the quantization table.  If you want to obscure that, you will need to replace that with the original camera tables.  It will almost certainly result in a further degradation of image quality, but I suspect that it would be small -- particularly if you could normalize the image data a little.

Second, there is the issue of obscuring the actual camera used to take a photograph.  Let's say you take a photograph of a police interaction and want to release the image to the press but live in a place that is both repressive and technologically sophisticated in terms of investigating dissident political activity.  In some areas, this will get you in prison.  It might be appropriate to modify the EXIF data so that it did not point to the camera you own, but to another manufacturer.

Thanks again!

billo

Archive

[Originally posted by exiftool on 2008-11-21 11:38:35-08]

Hi Billo,

I understand now, thanks. I'm not an expert on the JPEG encoder, but I
think the proper way to swap the tables would be to decode the image
then re-encode it with the desired set of tables.
I don't think it would be too hard to do this via the JPEG library routines,
but I have never tried this so I can't say for sure.

Swapping the tables in camera is ideal because the camera encodes the
JPEG from the original raw data, so there is no loss of quality. (In fact,
as you point out, you can increase the quality of the JPEG like this.)

Going the other direction (putting camera-specific tables back into
an edited image), it would be best to save the image in uncompressed
TIFF form in Photoshop, then run this custom software to JPEG-encode
the TIFF using a specific set of tables.  This makes more sense to me
than writing a JPEG from Photoshop then trying to swap the tables.

But you should be aware that it is possible to detect whether an image
has been edited by using various image analysis techniques, so just
setting the DHT/DQT tables doesn't solve everything.  For example,
the specific de-mosaicking algorithm may be identified fairly accurately
from an analysis of the image data itself, and this may be used to identify
the camera model that took the picture.

- Phil

Archive

[Originally posted by billo on 2008-11-22 01:09:53-08]


Thanks.  Yeah, since reconstructing an image from the quant table and the DCT data is basically a convolution, simply changing the DQT in the image would likely destroy it (though I haven't tried it, obviously).  Thus, you are right, there's no way to do it other than re-compressing with a given quant table.

The pipeline I forsee is something like this:

1. Extract the quantization table from a similar photo to the one you have but from a different camera.

2. Decode your image and put in some other format.

3. Recompress to jpeg, but force the use of the quantization table extracted in part 1.

4. Spoof the rest of the APP parts of the EXIF header.

I'm basically looking for tools to do 1 and 3.

I didn't think you could get the de-mosaicking algorithm from a single image without the RAW data.  Do you have a reference for that?

Archive

[Originally posted by exiftool on 2008-11-22 13:05:55-08]

Here's
that reference for you


They don't specifically mention JPEG-encoded images, but the
technique wouldn't be very useful otherwise.

- Phil

Archive

[Originally posted by billo on 2008-11-23 09:22:20-08]

Thanks!

billo