<s>
Quantization	B-Algorithm
,	O
involved	O
in	O
image	B-Algorithm
processing	I-Algorithm
,	O
is	O
a	O
lossy	B-Algorithm
compression	I-Algorithm
technique	O
achieved	O
by	O
compressing	O
a	O
range	O
of	O
values	O
to	O
a	O
single	O
quantum	O
(	O
discrete	O
)	O
value	O
.	O
</s>
<s>
Specific	O
applications	O
include	O
DCT	B-General_Concept
data	O
quantization	B-Algorithm
in	O
JPEG	O
and	O
DWT	O
data	O
quantization	B-Algorithm
in	O
JPEG	O
2000	O
.	O
</s>
<s>
Color	O
quantization	B-Algorithm
reduces	O
the	O
number	O
of	O
colors	O
used	O
in	O
an	O
image	O
;	O
this	O
is	O
important	O
for	O
displaying	O
images	O
on	O
devices	O
that	O
support	O
a	O
limited	O
number	O
of	O
colors	O
and	O
for	O
efficiently	O
compressing	O
certain	O
kinds	O
of	O
images	O
.	O
</s>
<s>
Most	O
bitmap	O
editors	O
and	O
many	O
operating	O
systems	O
have	O
built-in	O
support	O
for	O
color	O
quantization	B-Algorithm
.	O
</s>
<s>
Popular	O
modern	O
color	O
quantization	B-Algorithm
algorithms	O
include	O
the	O
nearest	O
color	O
algorithm	O
(	O
for	O
fixed	O
palettes	O
)	O
,	O
the	O
median	B-Algorithm
cut	I-Algorithm
algorithm	I-Algorithm
,	O
and	O
an	O
algorithm	O
based	O
on	O
octrees	B-Data_Structure
.	O
</s>
<s>
It	O
is	O
common	O
to	O
combine	O
color	O
quantization	B-Algorithm
with	O
dithering	O
to	O
create	O
an	O
impression	O
of	O
a	O
larger	O
number	O
of	O
colors	O
and	O
eliminate	O
banding	B-Algorithm
artifacts	O
.	O
</s>
<s>
This	O
is	O
the	O
main	O
lossy	B-Algorithm
operation	O
in	O
the	O
whole	O
process	O
.	O
</s>
<s>
These	O
blocks	O
can	O
then	O
be	O
subjected	O
to	O
discrete	B-General_Concept
cosine	I-General_Concept
transform	I-General_Concept
(	O
DCT	B-General_Concept
)	O
to	O
calculate	O
the	O
frequency	O
components	O
,	O
both	O
horizontally	O
and	O
vertically	O
.	O
</s>
<s>
The	O
resulting	O
block	O
(	O
the	O
same	O
size	O
as	O
the	O
original	O
block	O
)	O
is	O
then	O
pre-multiplied	O
by	O
the	O
quantization	B-Algorithm
scale	O
code	O
and	O
divided	O
element-wise	O
by	O
the	O
quantization	B-Algorithm
matrix	O
,	O
and	O
rounding	O
each	O
resultant	O
element	O
.	O
</s>
<s>
The	O
quantization	B-Algorithm
matrix	O
is	O
designed	O
to	O
provide	O
more	O
resolution	O
to	O
more	O
perceivable	O
frequency	O
components	O
over	O
less	O
perceivable	O
components	O
(	O
usually	O
lower	O
frequencies	O
over	O
high	O
frequencies	O
)	O
in	O
addition	O
to	O
transforming	O
as	O
many	O
components	O
to	O
0	O
,	O
which	O
can	O
be	O
encoded	O
with	O
greatest	O
efficiency	O
.	O
</s>
<s>
Many	O
video	O
encoders	O
(	O
such	O
as	O
DivX	B-Application
,	O
Xvid	B-Algorithm
,	O
and	O
3ivx	B-Algorithm
)	O
and	O
compression	O
standards	O
(	O
such	O
as	O
MPEG-2	B-Algorithm
and	O
H.264/AVC	B-Application
)	O
allow	O
custom	O
matrices	O
to	O
be	O
used	O
.	O
</s>
<s>
This	O
is	O
an	O
example	O
of	O
DCT	B-General_Concept
coefficient	O
matrix	O
:	O
</s>
<s>
A	O
common	O
quantization	B-Algorithm
matrix	O
is	O
:	O
</s>
<s>
Dividing	O
the	O
DCT	B-General_Concept
coefficient	O
matrix	O
element-wise	O
with	O
this	O
quantization	B-Algorithm
matrix	O
,	O
and	O
rounding	O
to	O
integers	O
results	O
in	O
:	O
</s>
<s>
By	O
using	O
a	O
zig-zag	O
ordering	O
to	O
group	O
the	O
non-zero	O
entries	O
and	O
run	B-Algorithm
length	I-Algorithm
encoding	I-Algorithm
,	O
the	O
quantized	O
matrix	O
can	O
be	O
much	O
more	O
efficiently	O
stored	O
than	O
the	O
non-quantized	O
version	O
.	O
</s>
