Quantization, involved in
image processingIn electrical engineering and computer science, image processing is any form of signal processing for which the input is an image, such as photographs or frames of video; the output of image processing can be either an image or a set of characteristics or parameters related to the image...
, is a lossy compression technique achieved by compressing a range of values to a single quantum value. When the number of discrete symbols in a given stream is reduced, the stream becomes more compressible. For example, reducing the number of colors required to represent a digital
imageAn image is an artifact, for example a two-dimensional picture, that has a similar appearance to some subject—usually a physical object or a person....
makes it possible to reduce its file size. Specific applications include
DCTA discrete cosine transform expresses a sequence of finitely many data points in terms of a sum of cosine functions oscillating at different frequencies...
data quantization in
JPEGIn computing, JPEG is a commonly used method of compression for photographic images. The degree of compression can be adjusted, allowing a selectable tradeoff between storage size and image quality...
and
DWTIn numerical analysis and functional analysis, a discrete wavelet transform is any wavelet transform for which the wavelets are discretely sampled...
data quantization in
JPEG 2000JPEG 2000 is a wavelet-based image compression standard. It was created by the Joint Photographic Experts Group committee in the year 2000 with the intention of superseding their original discrete cosine transform-based JPEG standard...
.
__FORCETOC__
Color quantization reduces the number of colors used in an image; this is important for displaying images on devices that support a limited number of colors and for efficiently compressing certain kinds of images.
Quantization, involved in
image processingIn electrical engineering and computer science, image processing is any form of signal processing for which the input is an image, such as photographs or frames of video; the output of image processing can be either an image or a set of characteristics or parameters related to the image...
, is a lossy compression technique achieved by compressing a range of values to a single quantum value. When the number of discrete symbols in a given stream is reduced, the stream becomes more compressible. For example, reducing the number of colors required to represent a digital
imageAn image is an artifact, for example a two-dimensional picture, that has a similar appearance to some subject—usually a physical object or a person....
makes it possible to reduce its file size. Specific applications include
DCTA discrete cosine transform expresses a sequence of finitely many data points in terms of a sum of cosine functions oscillating at different frequencies...
data quantization in
JPEGIn computing, JPEG is a commonly used method of compression for photographic images. The degree of compression can be adjusted, allowing a selectable tradeoff between storage size and image quality...
and
DWTIn numerical analysis and functional analysis, a discrete wavelet transform is any wavelet transform for which the wavelets are discretely sampled...
data quantization in
JPEG 2000JPEG 2000 is a wavelet-based image compression standard. It was created by the Joint Photographic Experts Group committee in the year 2000 with the intention of superseding their original discrete cosine transform-based JPEG standard...
.
__FORCETOC__
Color quantization
Color quantization reduces the number of colors used in an image; this is important for displaying images on devices that support a limited number of colors and for efficiently compressing certain kinds of images. Most bitmap editors and many operating systems have built-in support for color quantization. Popular modern color quantization algorithms include the nearest color algorithm (for fixed palettes), the
median cut algorithmMedian cut is an algorithm to sort data of an arbitrary number of dimensions into series of sets by cutting each set of data at the median point....
, and an algorithm based on
octreeAn octree is a tree data structure in which each internal node has up to eight children. Octrees are most often used to partition a three dimensional space by recursively subdividing it into eight octants. Octrees are the three-dimensional analog of quadtrees...
s.
It is common to combine color quantization with
ditheringDither is an intentionally applied form of noise, used to randomize quantization error, thereby preventing large-scale patterns such as "banding" in images, or noise at discrete frequencies in an audio recording, that are more objectionable than uncorrelated noise...
to create an impression of a larger number of colors and eliminate
bandingColour banding is a problem of inaccurate colour presentation in computer graphics. While in 24 bit colour modes, 8 bits per channel should be enough to render images in the full visible spectrum, in some cases there is a risk of producing abrupt changes between shades of the same colour...
artifacts.
Frequency quantization for image compression
The human eye is fairly good at seeing small differences in
brightnessBrightness is an attribute of visual perception in which a source appears to be radiating or reflecting light. In other words, brightness is the perception elicited by the luminance of a visual target...
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 a greatly reduced 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.
Quantization matrices
A quantization matrix is used in combination with a DCT coefficient matrix to carry out the previously mentioned transformation. Quantization matrices are often specifically designed to keep certain frequencies in the source to avoid losing image quality. Many video encoders, such as
DivXDivX is a brand name of products created by DivX, Inc. , including the DivX Codec which has become popular due to its ability to compress lengthy video segments into small sizes while maintaining relatively high visual quality.The DivX codec uses lossy MPEG-4 Part 2 compression, where quality is...
,
XvidXvid is a video codec library following the MPEG-4 standard, specifically MPEG-4 Part 2 Advanced Simple Profile . It uses ASP features such as b-frames, global and quarter pixel motion compensation, lumi masking, trellis quantization, and H.263, MPEG and custom quantization matrices.Xvid is a...
,
3ivx3ivx is a video codec created by 3ivx Technologies, based in Sydney, Australia.3ivx is a codec suite that allows the creation of MPEG-4 compliant data streams. It has been designed around a need for decreased processing power for use mainly in embedded systems. First versions was published in 2001...
and H.264/AVC allow custom matrices to be used.
This is an example of 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