Lossless JPEG transcoding Daniel Sanchez ECE 533 Fall





![Lossless JPEG transcoder [1] § How to modify decoder/encoder? Lossy JPEG Transcoder DC Huffman Lossless JPEG transcoder [1] § How to modify decoder/encoder? Lossy JPEG Transcoder DC Huffman](https://slidetodoc.com/presentation_image_h/fba70a8f2ff37c3de9a6471fcac24222/image-6.jpg)
![Lossless JPEG transcoder [2] JPEG Lossless Transcoder - Decoder DC Huffman IDPCM JPEG DC Lossless JPEG transcoder [2] JPEG Lossless Transcoder - Decoder DC Huffman IDPCM JPEG DC](https://slidetodoc.com/presentation_image_h/fba70a8f2ff37c3de9a6471fcac24222/image-7.jpg)


![Results of lossless rotation [1] Original image 10 Results of lossless rotation [1] Original image 10](https://slidetodoc.com/presentation_image_h/fba70a8f2ff37c3de9a6471fcac24222/image-10.jpg)
![Results of lossless rotation [2] Those strange manipulations actually work! Losslessly rotated image 11 Results of lossless rotation [2] Those strange manipulations actually work! Losslessly rotated image 11](https://slidetodoc.com/presentation_image_h/fba70a8f2ff37c3de9a6471fcac24222/image-11.jpg)
![Results of lossless rotation [3] Error when lossy rotation is applied 4 times § Results of lossless rotation [3] Error when lossy rotation is applied 4 times §](https://slidetodoc.com/presentation_image_h/fba70a8f2ff37c3de9a6471fcac24222/image-12.jpg)


- Slides: 14
Lossless JPEG transcoding Daniel Sanchez ECE 533 Fall 2006 Final Project Presentation University of Wisconsin-Madison
Overview § The problem of JPEG transcoding § Full-featured MATLAB JPEG codec § Lossless transcoder § Lossless rotation 2
The problem of JPEG transcoding § Basic JPEG decoder/encoder block diagrams: JPEG Decoder DC Huffman IDPCM DC JPEG File IQ AC Huffman De. Zig. Zag IDCT Level shifting YCb. Cr->RGB Image AC JPEG Encoder DC RGB Image RGB->YCb. Cr Level shifting DCT DPCM DC Huffman JPEG Q File AC Zig. Zag AC Huffman § Reencoding introduces errors because of the color model conversions (YCb. Cr<->RGB) 3
Implementing a JPEG codec in MATLAB § Extends the MATLAB JPEG Toolbox by Phil Sallee • http: //redwood. ucdavis. edu/phil/demos/jpegtbx/ • Includes functions that cover the more tedious parts of the codec JPEG Encoder Implemented Provided by toolbox DC RGB Image RGB->YCb. Cr Level shifting DPCM DC Huffman JPEG DCT Q File AC Zig. Zag AC Huffman § Works with most images! • Full color, arbitrary size, … • Some restrictions in subsampling and color models 4
Example of lossy reencoding Original image Error after reencoding (x 15) SNR=25. 1 d. B 5
Lossless JPEG transcoder [1] § How to modify decoder/encoder? Lossy JPEG Transcoder DC Huffman IDPCM DC JPEG File IQ AC Huffman De. Zig. Zag RGB->YCb. Cr Level shifting DCT Level shifting YCb. Cr->RGB Image AC DC RGB Image IDCT DPCM DC Huffman JPEG Q File AC Zig. Zag AC Huffman Reencoded coefficients are an estimation of the original ones -> Correct that estimation! 6
Lossless JPEG transcoder [2] JPEG Lossless Transcoder - Decoder DC Huffman IDPCM JPEG DC IQ File AC Huffman De. Zig. Zag Level shifting IDCT YCb. Cr->RGB AC RGB Image RGB->YCb. Cr Level shifting DCT Lossless Decompression Q + RGB->YCb. Cr Level shifting DCT Difference coefficients DPCM RGB Image Lossless Compression DC Huffman JPEG Q File Zig. Zag AC Huffman JPEG Lossless Transcoder - Encoder 7
Results of lossless transcoding Original image Transcoded image Difference coefficients (contrast ↑↑) § Lossy reencoding: SNR = 33. 2 d. B § Lossless transcoding: SNR = ∞ 8
Lossless rotation § Different approach: Operate on blocks directly • No need to requantize -> Lossless • Faster than decoding/encoding § To rotate an image (90º counterclockwise): • Rotate whole blocks (without modifying content) 1 2 3 3 6 9 4 5 6 2 5 8 • Perform the transformation G(u, v)=F(v, u)(-1)v on each block 7 8 9 1 4 7 □ This rotates the contents in the spatial domain! • Transpose quantization matrices (they are not symmetric in general!) 9
Results of lossless rotation [1] Original image 10
Results of lossless rotation [2] Those strange manipulations actually work! Losslessly rotated image 11
Results of lossless rotation [3] Error when lossy rotation is applied 4 times § § This time SNR=18. 1 d. B Lossy rotation degrades the quality much more than reencoding! 12
Applications of lossless transcoding § Image editing (allows editors to work with lossy compressed images without degrading quality) § Image rotation and other basic transformations (cropping, flipping, …) § Image transmission/storage 13
Thanks for your attention Any questions? 14