Friday 20 March 2009

Compression

Ok
I'm actually not only working on my bachelor project. I'm following another course and I'm working on my exam project for that course right now. The course is multimedia compression and I'm supposed to implement the compression steps of JPEG compression in Matlab. I'm not supposed to make JPEG files. I only have to make the transformations (DCT) forth and back and then save them as TIFFs. 
So as a real image processing guy I've used lenna or lena as my test image. I thought it might be fun to show how my lenna image looked like after compression and see how the image changes as I fixed some errors.

There are 3 sets of images showing the progress of my compression results where each set contains 2 images (except the final set). One compressed with quality 99 (the best quality) and one with quality 1 (give me a crappy picture quality). (Warning, I presume knwoledge of image compresssion in the following text, so if you don't understand a word just look at the pictures. It's not well written anyway. I'm pretty tired right now)

The original test image of lenna:

















First attempt at image compression of lenna (First image quality = 1 second quality = 99):

































Second attempt at compression. I've found out that the technique I had copied to change RGB to YCbCr was faulty so this was fixed for this attempt:

































The last and so far final attemp. I'm quite satisfied with the result. All the students were given a shell that we would have to fill out to make the compression. This shell called to functions. The first would convert the colours to YCbCr, subsample the chromonance channels, DCT and quantizise the images. The other would do the opposite. I had made a bunch of small functions to do all this work, so I only had to call the functions in the right order in the beforementioned two functions. 
Now I'm a programmer. That means I'm a bit lazy so after having written the first function I just copied it and pasted it into the second function and changed the function calls. Off course I would have to reorder it, so the inverse of the last step in the first function would be the first step in the second function. And I did that. Well at least I thought I did it. I realised that hadn't changed the order of dequantizising and inverse DCT, so I did IDCT before dequantizising my poictures. Doh.
Heres the final result (Q = 1, 20, 50 and 99):
      

First of all, boy is it annoying to add images to blogger :/ For some reason it insists to add the images at the top of my blog instead of were the cursor is.
Well anyway you can see quality 1 is horrible. But at quality = 20 you can the image is pretty good though you can see some block effects. I personally don't think theres to much difference between quality = 50 and 99 for this image.
In the end I'm quite pleased with results and now I only need to do some entropy coding so I can calculate my compression rate.

Until next time...

1 comment: