140 likes | 573 Views
Lossless JPEG transcoding. Daniel Sanchez. ECE533 Fall 2006 Final Project Presentation University of Wisconsin-Madison. Overview. The problem of JPEG transcoding Full-featured MATLAB JPEG codec Lossless transcoder Lossless rotation. The problem of JPEG transcoding.
E N D
Lossless JPEG transcoding Daniel Sanchez ECE533 Fall 2006 Final Project Presentation University of Wisconsin-Madison
Overview • The problem of JPEG transcoding • Full-featured MATLAB JPEG codec • Lossless transcoder • Lossless rotation
The problem of JPEG transcoding • Basic JPEG decoder/encoder block diagrams: • Reencoding introduces errors because of the color model conversions (YCbCr<->RGB) JPEG Decoder DC Huffman IDPCM DC Level shifting YCbCr->RGB JPEG File RGB Image IQ IDCT AC Huffman DeZigZag AC JPEG Encoder DC Huffman DPCM DC RGB->YCbCr Level shifting JPEG File RGB Image DCT Q AC ZigZag AC Huffman
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 • Works with most images! • Full color, arbitrary size,… • Some restrictions in subsampling and color models JPEG Encoder Implemented Provided by toolbox DC Huffman DPCM DC RGB->YCbCr Level shifting JPEG File RGB Image DCT Q AC ZigZag AC Huffman
Example of lossy reencoding Original image Error after reencoding (x15) SNR=25.1dB
Lossless JPEG transcoder [1] • How to modify decoder/encoder? Lossy JPEG Transcoder DC Huffman IDPCM DC Level shifting YCbCr->RGB JPEG File RGB Image IQ IDCT AC Huffman DeZigZag AC DC Huffman DPCM DC RGB->YCbCr Level shifting JPEG File RGB Image DCT Q AC ZigZag AC Huffman Reencoded coefficients are an estimation of the original ones -> Correct that estimation!
Lossless JPEG transcoder [2] JPEG Lossless Transcoder - Decoder DC Huffman IDPCM DC Level shifting YCbCr->RGB JPEG File RGB Image IQ IDCT AC AC Huffman DeZigZag - RGB->YCbCr Level shifting Difference coefficients Lossless Compression DCT Q + Difference coefficients Lossless Decompression DC Huffman DPCM RGB->YCbCr Level shifting JPEG File RGB Image DCT Q ZigZag AC Huffman JPEG Lossless Transcoder - Encoder
Results of lossless transcoding • Lossy reencoding: SNR = 33.2 dB • Lossless transcoding: SNR = ∞ Difference coefficients(contrast ↑↑) Original image Transcoded image
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) • Perform the transformationG(u,v)=F(v,u)(-1)v on each block • This rotates the contents in the spatial domain! • Transpose quantization matrices (they are not symmetric in general!)
Results of lossless rotation [1] Original image
Results of lossless rotation [2] Those strange manipulations actually work! Losslessly rotated image
Results of lossless rotation [3] Error when lossy rotation is applied 4 times • This time SNR=18.1 dB • Lossy rotation degrades the quality much more than reencoding!
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
Thanks for your attention Any questions?