I am developing an image viewer/editor using VS2008 ,MFC and WIC and I would like to recompress jpegs as closely (quality-wize) as possible to their original, after image processing. Does anyone know how to extract luminance and chrominance tables to set in
http://msdn.microsoft.com/en-us/library/gg430026%28v=vs.85%29.aspx
WITHOUT having to use an additional large library (like libjpeg)?
Asked
Active
Viewed 1,929 times
2

Pifcnt
- 117
- 1
- 10
-
Even if you obtained the tables, you will still need to extract the DC and AC coefficients of each image block (which encodes the *content* of the image). WIC doesn't provide a *public* interface for doing so. (WIC does support lossless re-encoding functionality, and this feature is implemented by making use of certain private interfaces, which we don't have access to.) – rwong Jul 01 '11 at 06:56
1 Answers
3
The JPEG standard specification covers the details of the luminance and chrominance table.
In JPEG terminology, those tables are both referred to as "quantization table" (DQT). The luminance quantization table is applied on the "Y" channel and the chrominance quantization table is applied to "Cb" and "Cr" channels.
This website lists the quantization tables for a large number of camera manufacturers and JPEG authoring software.
To recompress an image using the same quantization tables as another existing image:
- Query and enumerate all IWICMetadataBlockReader objects from the source image (IWICBitmapFrameDecode).
- Find the metadata blocks which have the types GUID_MetadataFormatJpegChrominance and GUID_MetadataFormatJpegLuminance
- Extract their binary data, and use those data to initialize the Luminance and Chrominance properties of the JPEG encoder options by putting them into the IPropertyBag when calling IWICBitmapFrameEncode::Initialize.

rwong
- 6,062
- 1
- 23
- 51
-
1I am assuming this works. However the answer came too late as I moved away from the project and the company needing this. Thank you for the effort anyway. – Pifcnt Sep 15 '11 at 14:08