I can only barely comprehend what you are trying to do or why, but
unless the reference image is a lossless JPEG (I assume not, if it has a
DQT), any decompression/compression cycle will result in generational
loss. Thus, you cannot exactly regenerate a lossy reference JPEG image
unless you have the original uncompressed image that was used to
generate the reference image in the first place. Once a JPEG image is
generated, then some of that original data is lost. The best you can do
is copy the DCT blocks (in the frequency domain) from one JPEG container
to another, which is what jpegtran does. That avoids a
decompression/recompression cycle and thus avoids generational loss, so
the transformed JPEG image has no additional loss relative to the
reference JPEG image. However, there are limits to what you can do in
the frequency domain. You can reorder the DCT blocks; spatially
transpose, rotate, or flip the blocks; remove or change the order of
some of the component planes (e.g. convert color to grayscale); negate
the coefficients (photo negative); re-quantize the coefficients (lower
the effective JPEG quality); change the entropy algorithm (e.g. convert
baseline to progressive or arithmetic); add restart markers; crop the
image (by discarding certain blocks); wipe an image region (by greying
out certain blocks); drop another image into the source image (by
replacing certain blocks); or remove metadata.
On 6/28/23 3:59 PM, Hugh Shaw wrote:
I have a specific requirement I need help with and hope to get
assistance from experts in the field. I have learned that for the same
compression algorithm, the compression fingerprints are consistent.
This means that the data from FF D8 to just before the scan line FF DA
are always identical. Based on this information, I would like to be
able to duplicate the compression fingerprint of one image and apply
it to another.
Specifically, I need to accomplish two things:
First, use the perfectly compressed fingerprint from reference.jpg to
compress input.jpg and generate output.jpg. Second, make sure that the
DQT, SOF, and DHT information in output.jpg is exactly the same
(including hex codes) as in reference.jpg. I have already ensured that
the pixel dimensions of input.jpg and reference.jpg are the same.
I have attempted to code a solution, as shown below, which involves
manually copying the quantization and Huffman tables, copying critical
parameters, and applying the compression and decompression. However,
the resulting output.jpg differs in hex code from the reference image,
even though the dimensions are the same.
/Due to lenght limitations, I can only include the code I tried in the
attachment/
I am unsure what the issue is and would appreciate any guidance in
resolving this problem. Thank you.
Looking forward to your reply!
Best regards,
--
You received this message because you are subscribed to the Google
Groups "libjpeg-turbo User Discussion/Support" group.
To unsubscribe from this group and stop receiving emails from it, send
an email to libjpeg-turbo-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit
https://groups.google.com/d/msgid/libjpeg-turbo-users/db388722-522d-40f7-b868-185684060ffan%40googlegroups.com
<https://groups.google.com/d/msgid/libjpeg-turbo-users/db388722-522d-40f7-b868-185684060ffan%40googlegroups.com?utm_medium=email&utm_source=footer>.
--
You received this message because you are subscribed to the Google Groups
"libjpeg-turbo User Discussion/Support" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to libjpeg-turbo-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit
https://groups.google.com/d/msgid/libjpeg-turbo-users/19730cdb-f485-659e-b382-60eeb441f2cc%40virtualgl.org.