The blog of Jafar Aliyev


Home :: Programming :: Solutions

Creation date:

Rasterization program(2001)

This image compression program based on JPEG algorithm and customized to get tiny photos. In one of projects whe was required to compress photo to be less than 1 Kbyte to keep it in PDF417 2D barcode beside the personal information. But the face must be remain recognizable. There was no chip these times.

This program customized to compress human portraits. For this purpose I reduced the size and bit depth of image to be 5 bits. Then took off chrominance, applied Discrete Cosine Transform(DCT), zigzag reordering of each block, the quantization, and Huffman algorithm. Block I read in concentric manner. Central blocks are less compressed than thoose far from face. It gives the best quality on face and less quality on periferic part of image. If the requirement on final image is more than 1KB you can even compress color portraits.

To test the compression open a photo as color or grayscale, then compress in memory to see the result. You will have to provide maximum size of image and algorithm will calculate the compression ratio. Program saves the files with J extension. Don't save compressed in memory image or the program will compress it twice. Instead open a fresh copy of image and save to J format. You can read this J image later. See below an original image and after compression. The size of compressed image is 960 bytes.

before after

When read the image program enhances and makes image a bit sharpen.

Program is provided in 3 versions:
Raster.exe - Standalone to check application.
JComp.dll - Dll for programmers
JCompOCX.ocx - ActiveX dynamic library version

The wavelet based compression version is available on Incomplete projects page.

Author: Jafar N.Aliyev (Jsoft)
Source: Included (Borland C for Windows)
License: Free

Download here