The image_scz and image_dscz programs implement simple image compression/decompression, respectively. They reduce space required to store photographic images, are based on the SCZ core compression algorithm, and can be included within other applications. The image_scz and image_dscz programs are released as companions to the SCZ (Simple Compression) routines.
Image_scz accepts PPM image files and preprocesses them into a form that is more compressible, and then applies the normal SCZ compression. Specifically, it quantizes the differences between pixels in adjacent columns. The differences are quantized in a mu-law-like distribution so that small changes can be resolved. The quantization causes a small loss in image information, but increases the number of exact patterns that can be exploited by the normal compression algorithm.
On decompression with Image_dscz, the process is reversed. The processed image data is decompressed with the regular SCZ algorithm, and then the preprocessing is reversed by integrating the column-differences.
Presently, these routines are set to work only on PPM or PNM image formats. Other variants could be made. PPM/PNM formats are convenient because the format is well-known and straight-forward. In PNM the pixel values are recorded in a simple 2D-matrix with no compression, other than perhaps packing the binary pixel values as one (0-255) RGB value per byte. Commonly available tools such as GIMP, Image-Magik, XV, and Net-PBM can convert virtually any other format to/from PNM. (No need in re-inventing all the format conversion functions.)
Quality can be controlled with the (-q xx) Quanta setting. The default value is 8. Setting it to a lower value, such as 5 or 6, gives better compression, but lower quality images. Values of 10,12,16... give better quality images, but less compression.
An interesting aspect of this compression method is that successive compressions/decompressions of a given image do not degrade image quality, as will occur for instance with JPEG. Instead, the loss occurs once, during the first compression only. This compression method will not compress quite as compactly as JPEG for a given quality level, however it will get you 9/10's the way with only 1/10 the code and dependencies. Also, the code/algorithm appear easier to understand and are simpler than JPEG.
Image_scz Options:
Image_scz accepts .ppm or .pnm files and produces compressed .iscz files. Image_dscz accepts .iscz files and produces decompressed .ppm files.
Example 1:
image_scz snapshot.ppm
(Writing output to snapshot.iscz)
image_dscz snapshot.iscz
Decompression ratio = 9.4
(Writing output to snapshot.ppm)
Example 2:
image_scz -q 6 snapshot.ppm
(Writing output to snapshot.iscz)