Intel® Integrated Performance Primitives
Deliberate problems developing high-performance vision, signal, security, and storage applications.

JPEG lossless transform

levicki
Valued Contributor I
591 Views
In short, is it supported in UIC or IPP?

I need a lossless rotation of JPEG image.
0 Kudos
8 Replies
Thomas_Jensen1
Beginner
591 Views
I asked this question a while back, and the answer was no.
I use my own JpegTrans.dll, compiled from IJG, however I not sure if it can handle anything outside baseline jpeg.

See:
ipp-samples\image-codecs\ijg\samples\utils\jpegtran.c
0 Kudos
Vladimir_Dudnik
Employee
591 Views
What do you call as lossless JPEG rotation? If that is technique used in IJG library than it is not mathematically lossless and is not necessary faster then just full decode and rotate.

What widely called as JPEG lossless rotate is partial decoding up to final up-sampling and color conversion steps, that is:

1. huffman decode of DCT coefficients
2. dequantization
3. inverse DCT transform (which brings data from frequency domain back to time domain and produceimage pixels)
- here is the point where it is possible to rotatepixel data before the final step, which is up-sampling (if needed) and color conversion (if needed)

First, the only mathematically lossless operation here is huffman decoding.
Second, performance of IPP implementation of up-sampling and color-conversion functions reduce difference in time required to that "lossless rotate operation" and just naive full decoding and rotate.

Regards,
Vladimir
0 Kudos
levicki
Valued Contributor I
591 Views
Vladimir,

I should perhaps said "reversible" instead of "lossless" and clarified that I mean 90, 180 and 270 rotation and flipping.

As far as I know JPEGTRAN does not perform dequantization and IDCT, but instead transforms MCU blocks, AC coefficient matrices, and changes chroma subsampling orientation.

Lossless crop is also possible as long as you crop along MCU boundaries.

Finally, chrominance channels can be discarded for simple and fast grayscale conversion without recompression.

You might want to read through this carefully:
http://www.impulseadventure.com/photo/lossless-rotation.html

Full decompression and rotation is fast enough for display, but I want to be able to save the rotated file without the loss of quality associated with full JPEG recompression.

0 Kudos
Vladimir_Dudnik
Employee
591 Views
Hm, do you mean jpegtran do all these reversible flipping in frequency domain?

Vladimir
0 Kudos
levicki
Valued Contributor I
591 Views
Sure, that's the whole point.

If you don't believe me, try it and compare results of conventional rotation with recompression and reversible rotation. There are a lot of programs supporting reversible transforms nowadays.

0 Kudos
artemmikheevgmail_co
591 Views
Perhaps you should specify that you want rotation angles be x90 degrees. Though it could be lossless for 45 degree increments too with a little more work. You can not do it for an abitrary angle.
0 Kudos
levicki
Valued Contributor I
591 Views
I did in this post.
0 Kudos
Thomas_Jensen1
Beginner
591 Views
You are wrong in this statement. Lossless jpeg rotation means only huffman decoding, DCT rotation/mirror, huffman encoding.

To put it simply, no new jpeg artifacts are introduced with lossless rotation.
You can repeat lossless rotation infinitely without destroying the image.

The only issue are the right and bottom borders, because they are not on an 8x8 boundary.
If the original image is modulo 8x8, rotation/mirror is purely lossless.
0 Kudos
Reply