Intel® Integrated Performance Primitives
Community support and discussions relating to developing high-performance vision, signal, security, and storage applications.
Announcements
This community is designed for sharing of public information. Please do not share Intel or third-party confidential information here.

JPEG lossless transform

ILevi1
Valued Contributor I
171 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
171 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
Vladimir_Dudnik
Employee
171 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
ILevi1
Valued Contributor I
171 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.

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

Vladimir
ILevi1
Valued Contributor I
171 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.

artemmikheevgmail_co
171 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.
ILevi1
Valued Contributor I
171 Views
I did in this post.
Thomas_Jensen1
Beginner
171 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.
Reply