A Matlab Playground for JPEG Andy Pekarske Nikolay Kolev.

11
A Matlab Playground for JPEG Andy Pekarske Nikolay Kolev

Transcript of A Matlab Playground for JPEG Andy Pekarske Nikolay Kolev.

Page 1: A Matlab Playground for JPEG Andy Pekarske Nikolay Kolev.

A Matlab Playground for JPEG

Andy Pekarske

Nikolay Kolev

Page 2: A Matlab Playground for JPEG Andy Pekarske Nikolay Kolev.

What is JPEG

• We explored the information flow during transformation of images from their basic bitmap format to compressed coefficients streams.

• We also undertook the task to construct a JPEG decoder which uses the compressed binary coefficient sequences and converts them back into viewable images.

• This allowed us to analyze better the complete cycle of image compression and at the same time to be able to understand and explore the complete process which is undertaken when compressing, storing, transmitting and rebuilding an image with JPEG.

Page 3: A Matlab Playground for JPEG Andy Pekarske Nikolay Kolev.

Improvement Possibilities

• Adhering to the standard’s original scheme, we wanted to explore and implement various self-contained techniques that could lead to better image quality and higher compression ratio.

1. We wanted to verify that DCT (Discrete Cosine Transform) is the best choice for image energy/frequency compaction transform. Theoretically FFT (Fast Fourier Transform) is also an acceptable (actually the first) method for frequency analysis of time and space signals, although our conclusion was that DCT is a better choice.

2. The lossy compression portion of JPEG achieved through block coefficient quantization could be made less “lossy” and more efficient at the same time by choosing in a more sophisticated way which coefficients should be stripped of precision and which retained with high precision at this stage of the overall image compression.

3. Theoretically it could be shown that Arithmetic Encoding could be a better and more efficient technique for lossless compression than Huffman Encoding.

Page 4: A Matlab Playground for JPEG Andy Pekarske Nikolay Kolev.

Designing the Huffman Decoder

• Having a JPEG encoder initially, we had to design a decoder in order to make the process useful.

• It was interesting to learn that the reverse process (decoding) of Huffman coding is quite more computationally intensive than the encoding portion of this lossless compression technique.

Page 5: A Matlab Playground for JPEG Andy Pekarske Nikolay Kolev.

DCT vs. FFT

• At first sight FFT should be a good substitute for DCT, as both take as input nxn blocks and produce nxn coefficient blocks and both feature perfect reconstruction.

• We could not prove that assumption in our project. FFT gives a very blurry result for any image processed with FFT.

Page 6: A Matlab Playground for JPEG Andy Pekarske Nikolay Kolev.

Optimizing Quantization

• We believe that the lossless portion of JPEG could be less lossy if a more sophisticated method for coefficient quantization is utilized.

• Our test program allows for experimenting with this parameter of JPEG and we implemented portion of selective algorithm that allows for compression level choice.

Page 7: A Matlab Playground for JPEG Andy Pekarske Nikolay Kolev.

Implementing Arithmetic Encoding

• We had to construct a complementary coding pair: Arithmetic Encoder/Decoder in order to be able to compare Arithmetic with Huffman coding.

• We utilized two Matlab functions arithmenco( ) and artithmdeco( ) to implement this feature.

• We realized that is quite challenging to come up with a good encoding scheme and to design an efficient interface so that there is a robust coupling between encoder and decoder

Page 8: A Matlab Playground for JPEG Andy Pekarske Nikolay Kolev.

Visual Results…Original 64x64 128x128

DCT,

Huffman

DCT, Arithmetic

Here default quantization is used

Page 9: A Matlab Playground for JPEG Andy Pekarske Nikolay Kolev.

Here adaptive (higher in the case) quantization is used

… Visual ResultsOriginal 64x64 128x128

DCT,

Huffman

DCT, Arithmetic

Page 10: A Matlab Playground for JPEG Andy Pekarske Nikolay Kolev.

Conclusions

• Switching an image encoder/decoder to use different types of Frequency Domain transforms is not a trivial task

• Quantization matrix choice is very important for achieving good compression ratio without loss of quality

• As expected, images processed by Arithmetic encoding are identical to images undergone Huffman lossless compression

• Arithmetic encoding could be a better scheme for lossless compression but requires a much more sophisticated algorithm than that in Huffman method in order to make this hold in practice.

Page 11: A Matlab Playground for JPEG Andy Pekarske Nikolay Kolev.

Demonstration and Questions

• Demonstration of Matlab code and conducted experiments

• Audience chance to experiment with Matlab program

• Questions