Image compression

Image compression based as any application of data compression it to convert the original data either in a completely reconstructed form that requires less space or remove data whose loss is hardly noticeable. There are a lot of image file formats ( graphic formats), but of which many are outdated and no support many compression since they are formats for exchange of graphics programs.

Lossless Compression

In lossless compression no information is lost. The data is different than the previously illustrated, by detecting and removing certain redundancies. For example, repetitive bit strings can be stored in a dictionary and then represented only by their number once. Known method, the run length coding, LZW or Huffman coding. It may be any general compression method may be used, which can also be applied to other types of data such as text.

The graphics format PNG used as Deflate compression method, a combination of LZ77 and Huffman coding. The good compression of PNG explained (also called " pre-filter " in PNG ) through the additional use of predictive coding. The next color values ​​are empirical values ​​predicted and only the deviations from the prediction of the actual image information is stored.

The graphics format used for compressing GIF, however, only the LZW algorithm and therefore usually does not achieve such good compression like PNG. Also, it can only display 256 colors per frame, but it also animations.

A good compression factor can be with these processes, however, only be obtained if the images are favorable to the compression algorithms. This means they should as large as possible areas each having the same color or exactly the same pattern in PNG possibly also with gradients, possess.

Also, Lossless JPEG, JPEG 2000 and allow WebP lossless compression, the latter even more complex images with still quite good compression rate.

Lossy compression

When lossy compression is trying to keep the loss of information imperceptibly, or at least aesthetically bearable. These methods exploit the fact that small color changes to the eye are not visible. Similar to the lossy audio compression, the image compression is based on a model of human perception. The compression algorithm should preferably remove the image information that is beyond the capacity of the human image perception. The perceptual model, however, in contrast to the audio compression is not explicitly formulated and incorporated into the algorithm, but more intuitive.

JPEG and JPEG 2000

In the JPEG method, the image with the help of a system of basis functions is transformed. JPEG is the discrete cosine transform, JPEG 2000 wavelet transformation. In this manner, other equivalent representation of the image, which consists of the coefficients for these basic functions. JPEG are the amplitudes of the so-called spatial frequencies, in JPEG 2000, a kind of an average over 4, 16, 64, ... pixels. These coefficients are changed by the quantization. Small coefficients disappear and the larger will be set to the nearest value. Thus, they can be represented with fewer bits. Finally, a lossless data compression is still carried out.

The newer JPEG 2000, however, could not yet prevail, since the necessary algorithms for digital cameras and other portable devices can be computationally expensive and legal ambiguities relating to licensing (software patents) exist.

The largest visual problems ( compression artifacts) with excessive JPEG compression prepares the formation of so-called blocking artifacts that arise in small blocks in the distribution of the image, as well as Ringing, a consequence of the unfavorable behavior of the discrete cosine transform with sharp color transitions.

Fractal image compression

Another lossy method, but could not prevail in graphic formats widely itself, is fractal image compression. It is based on the discovery of chaos theory that almost every image has self-similarity. Here, to groups of pixels of a certain size (eg, 8 × 8 points) similar groups of the next smaller size (4 × 4 points) wanted the same image. Are then stored in place of the actual position of the similar groups, only the reference groups, which have less image data. This method essentially corresponds to a codebook method, with the difference that the codebook does not need to be stored separately, but is in the same stock. As the search for similar groups can be quite costly, if necessary, this neural networks are used. The decoding is, however, not be more complex than in conventional methods.

Compression method in comparison

The common formats have advantages and disadvantages and are therefore suitable for the particular purpose more or less well. Computer graphics that contain hard edges - about simple graphics or screenshots - can usually be compressed better by lossless method, as the following comparison shows:

GIF: 1847 bytes

JPEG: 4273 bytes

WebP lossless: 908 bytes

It is clear to see that despite the large JPEG file size is visible artifacts. PNG compressed here much better than GIF and outputs the image still true to the original.

In photographs and graphical images like JPEG is not among the common formats, the first choice when space plays a role. Lossless formats such as PNG are usually not for photographs, as they produce significantly larger files. In GIF there is the added restriction to 256 colors per frame.

In the professional field (such as in prepress ) usually find lossless formats or Vector graphics use, since there is the possibility of multiple processing more important than the memory consumption; also the image quality is better than JPEG. Here TIFF is usually used because it also supports used in printing CMYK color model. Lossless raw formats also offer the greatest opportunities and best quality for photographs. But there are also " Mixed Sizes " as JPEG 2000, where lossless and lossy compression can be combined.

The most important and best supported video formats for animations are GIF, Flash, Shockwave, and SVG.