Task 014: Transform compression of grayscale image

Your task is to implement lossy compression of grayscale raster image, you should be focused on natural images taken with digital camera or results of synthetic CGI rendering.


Entropy codec

There is a standard vocabulary-based entropy codec ready for you: DeflateStream (Zlib) or a more effective buffered version BufferedDeflateStream.


You should choose suitable image transform and implement lossy compression scheme based on it. Codec efficiency will be your goal .. good compression ratio withing reasonable image quality boundaries (measured as RMSE). The whole codec will be implemented in one class TRCodec - in one source file TRCodec.cs.


You will be using the 014compressiontr project from the grcis repository. The simple WinForms-based application is ready, user can load an input image and start encoding/decoding by pressing the button Recode. After a short time encoding and recoding will finish and you will be informed about results: time spent in encoding phase, size of intermediate binary file and RMSE measured on the result image.

Please ignore eventual input-image colors, read input data using Raster.Draw.RgbToGray(). Put raster image size together with a magic number MAGIC into the header of your file-format.

Metods to implement: EncodeImage() and DecodeImage().


Use some classical image transform (DCT, Hartley, Hadamard, Haar..). Then quantize coefficients individually (like in JPEG-1), quality controlled by an user will be appreciated (see JPEG-1 again). Final coefficient pass and some proper channel coding will finish the encoding task.

Decoding should invert exactly the channel coding step and the transform step (except of possible numerical errors). So called "dequantization" will introduce all the distortion..

Comparison: the JPEG standard, but you probably won't be able to compete.


Pilot implementation is ready for you (in 014compressiontr project): user can load arbitrary input image, enter required quality (between 0 and 100) and start encoding. After encoding/decoding is done, you can see time spent in encoding, size of intermediate binary file (compressed image) and RMSE of the reconstructed image.


Due to: 17. 1. 2016


Base: 25 points (functional code with reasonable efficiency), bonus points for good efficiency, testing more than one transform or more extensive study (separate document/report handed in).


Visual Studio project: 014compressiontr.

Source file

Modify and submit the file: TRCodec.cs
Put your name into the comment on the first line.
Describe yourt method at least in source=file comments.

Results / contest

Not yet.

Input data

There is one image in the repository - masa512g.png more suitable images: janssen-19111g.png (533x400), kodim07sg.png (465x375) nebo frozentree.png (1920x1200).

Copyright (C) 2010-2015 J.Pelikán, last change: 2015-12-17 00:33:18 +0100 (Thu, 17 Dec 2015)