Quantization (image processing)

This is an old revision of this page, as edited by Omegatron (talk | contribs) at 03:38, 13 March 2006 (Regex dash fixer). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.

Quantization, involved in image processing. Quantization techniques generally compress by compressing a range of values to a single quantum value. By reducing the number of discrete symbols in a given stream, the stream becomes more compressible. For example seeking to reduce the number of colors required to represent an image. Another widely used example — DCT data quantization in JPEG and DWT data quantization in JPEG 2000.

Quantization in file formats

Although more frequent in the past, nowadays color quantization with pallets of lower than 256 colours is mainly used in GIF and PNG images. Using "nearest-neighbor" quantization and allowing fewer colours usually results in smaller file sizes, however sophisticated "random dithering" can actually inflate the final size.

The infinite number of colors available through the lens of a camera is impossible to display on a computer screen. Since a computer can display only a finite number of colors, quantization is always necessary.

Many early computers were limited in the number of colors they could display at one time — commonly 16 (and later 256) colours. Modern computers can now display millions of colours at once, far more than can be distinguished by the human eye.

Most quantization algorithms allow you to set exactly how many colors you want to use. With the few colors available on early computers, different quantization algorithms produced very different-looking output images. As a result, a lot of time was spent on writing sophisticated algorithms to be more lifelike. Nowadays almost every algorithm produces an output indistinguishable from the view through the camera lens.

Quantization algorithms

A standard quantization algorithm works in 2 steps:

  1. Analyze the image's color usage to select the new color palette.
  2. Dither the image to the new color palette.

A common quantization algorithm is the Octree-based algorithm, as described in the MSDN article on ASP.NET color quantization.

Another popular quantization algorithm is the "median cut" algorithm.

Quantization in image compression

The human eye is fairly good at seeing small differences in brightness over a relatively large area, but not so good at distinguishing the exact strength of a high frequency brightness variation. This fact allows one to get away with greatly reducing the amount of information in the high frequency components. This is done by simply dividing each component in the frequency ___domain by a constant for that component, and then rounding to the nearest integer. This is the main lossy operation in the whole process. As a result of this, it is typically the case that many of the higher frequency components are rounded to zero, and many of the rest become small positive or negative numbers.

This is an example DCT coefficient matrix:

 

A common quantization matrix is:

 

Using this quantization matrix with the DCT coefficient matrix from above results in:

 

For example, using −415 (the DC coefficient) and rounding to the nearest integer