Content deleted Content added
m Someone forgot a full stop |
Extend description + DCT quantization section from JPEG |
||
Line 1:
'''Quantization''', involved in [[image processing]]
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.
Line 10:
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.
===Quantization algorithms===
A standard quantization [[algorithm]] works in 2 steps:
#Analyze the image's color usage to select the new color palette.
Line 19:
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.
A common quantization matrix is: <!--FIXME: where does this matrix come from? afaict this is exactly the part that would change with encoder and quality setting so calling it common seems a bit of a stretch especially with no source [[User:Plugwash|Plugwash]] 12:30, 23 May 2005 (UTC)-->
:<math>
\begin{bmatrix}
16 & 11 & 10 & 16 & 24 & 40 & 51 & 61 \\
12 & 12 & 14 & 19 & 26 & 58 & 60 & 55 \\
14 & 13 & 16 & 24 & 40 & 57 & 69 & 56 \\
14 & 17 & 22 & 29 & 51 & 87 & 80 & 62 \\
18 & 22 & 37 & 56 & 68 & 109 & 103 & 77 \\
24 & 35 & 55 & 64 & 81 & 104 & 113 & 92 \\
49 & 64 & 78 & 87 & 103 & 121 & 120 & 101 \\
72 & 92 & 95 & 98 & 112 & 100 & 103 & 99
\end{bmatrix}
</math>
Using this quantization matrix with the DCT coefficient matrix from above results in:
:<math>
\begin{bmatrix}
-26 & -3 & -6 & 2 & 2 & -1 & 0 & 0 \\
0 & -3 & -4 & 1 & 1 & 0 & 0 & 0 \\
-3 & 1 & 5 & -1 & -1 & 0 & 0 & 0 \\
-4 & 1 & 2 & -1 & 0 & 0 & 0 & 0 \\
1 & 0 & 0 & 0 & 0 & 0 & 0 & 0 \\
0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 \\
0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 \\
0 & 0 & 0 & 0 & 0 & 0 & 0 & 0
\end{bmatrix}
</math>
For example, using −415 (the DC coefficient) and rounding to the nearest integer
:<math>
\mathrm{round}
\left(
\frac{-415}{16}
\right)
=
\mathrm{round}
\left(
-25.9375
\right)
=
-26
</math>
==External links==
* [http://www.compression-links.info/Quantization List of papers and resources about quantization]
{{Comp-stub}}
|