Task 011: Lossless compression of B/W image

Your task is to implement lossless compression of two-color raster image (one bit per pixel), you should be focused on images with many thin lines/curves - scanned handwriting using a thin pen.

Screenshot

Entropy codec

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

Base

You will be using the 011compressionbw 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 number of pixel errors (this number should be zero as your codec should be lossless!).

Details

Your task is to design and implement your own compression algorithm and check its "losslessness". The whole codec (encoder & decoder) will be implemented in one class BWCodec - in one source file BWCodec.cs.

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

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

Ideas

Predictive compression (e.g. 8-pixel neighborhood), some form of line-tracking, inter-line redundancy, vocabulary of little patterns (2x2px to 4x4px), quad-tree principle, ..

Comparison/benchmarking: compression in PNG format or specialized TIFF - Fax 4 (the later one is very good, don't be intimidated by it, you don't need be such good).

Deadline

Due to: 7. 1. 2018

Credits

Base: 25 points (functional code, has to be lossless!), bonus points for interesting idea and efficiency (contest).

Project

Visual Studio project: 011compressionbw.

Source file

Modify and submit the file: BWCodec.cs
Return your name in the InitParams() function!

Input data

TEST DATA: there is one image in the repository: santa.png (but it doesn't match our criteria very well), more images: zadani1.png (1393x689), lukas1.png (909x451), lukas2.png (1294x900), masa2.png (1372x1075), handwr03.png (1152x749), hodnoceni.png (1301x910), bad.png (500x357).


Copyright (C) 2010-2017 J.Pelikán, last change: 2017-11-15 23:22:25 +0100 (Wed, 15 Nov 2017)