Photo-Image SCZ Compression                       August 14, 2007
The primary SCZ routines are useful for compressing text, XML, line-drawing/diagram images, scans of text pages, or other types of binary computer data. However, they are unable to compress photographic images very much because they implement loss-less methods that can only reduce exactly repeated patterns within data which are common in the above file types but not in photographic images. Here we speak of photographic images that are, for example, pictures taken with cameras of the real-world containing many features; not drawings or cartoons which contain large flat-color areas. The core SCZ compress and decompress routines restore data perfectly to the exact binary values, like GZip or Zip. But this is often not as important with image data, because the human eye can not discern exact binary values. Therefore, special lossy image compression routines have been developed, such as JPEG, that take advantage of human perception effects to restore images which appear to match the original visually, but are not exactly binary equivalent to the original files. Recently, a new pair of routines has been added to SCZ for efficient photo-image compression.

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)

Downloading SCZ

      image_scz_2_28_08.tgz   v0.7   February 28, 2008


Return to SCZ-Main Page Logo