<s>
frame|An	O
example	O
image	O
in	O
24-bit	O
RGB	O
colorframe|The	O
same	O
image	O
reduced	O
to	O
a	O
palette	B-Data_Structure
of	O
16	O
colors	O
specifically	O
chosen	O
to	O
best	O
represent	O
the	O
image	O
;	O
the	O
selected	O
palette	B-Data_Structure
is	O
shown	O
by	O
the	O
squares	O
at	O
the	O
bottom	O
of	O
the	O
image	O
.	O
</s>
<s>
In	O
computer	O
graphics	O
,	O
color	B-Algorithm
quantization	I-Algorithm
or	O
color	B-Algorithm
image	I-Algorithm
quantization	I-Algorithm
is	O
quantization	B-Algorithm
applied	O
to	O
color	B-Algorithm
spaces	I-Algorithm
;	O
it	O
is	O
a	O
process	O
that	O
reduces	O
the	O
number	O
of	O
distinct	O
colors	O
used	O
in	O
an	O
image	O
,	O
usually	O
with	O
the	O
intention	O
that	O
the	O
new	O
image	O
should	O
be	O
as	O
visually	O
similar	O
as	O
possible	O
to	O
the	O
original	O
image	O
.	O
</s>
<s>
Computer	O
algorithms	O
to	O
perform	O
color	B-Algorithm
quantization	I-Algorithm
on	O
bitmaps	O
have	O
been	O
studied	O
since	O
the	O
1970s	O
.	O
</s>
<s>
Color	B-Algorithm
quantization	I-Algorithm
is	O
critical	O
for	O
displaying	O
images	O
with	O
many	O
colors	O
on	O
devices	O
that	O
can	O
only	O
display	O
a	O
limited	O
number	O
of	O
colors	O
,	O
usually	O
due	O
to	O
memory	O
limitations	O
,	O
and	O
enables	O
efficient	O
compression	O
of	O
certain	O
types	O
of	O
images	O
.	O
</s>
<s>
The	O
name	O
"	O
color	B-Algorithm
quantization	I-Algorithm
"	O
is	O
primarily	O
used	O
in	O
computer	O
graphics	O
research	O
literature	O
;	O
in	O
applications	O
,	O
terms	O
such	O
as	O
optimized	O
palette	B-Data_Structure
generation	O
,	O
optimal	O
palette	B-Data_Structure
generation	O
,	O
or	O
decreasing	O
color	O
depth	O
are	O
used	O
.	O
</s>
<s>
Some	O
of	O
these	O
are	O
misleading	O
,	O
as	O
the	O
palettes	B-Data_Structure
generated	O
by	O
standard	O
algorithms	O
are	O
not	O
necessarily	O
the	O
best	O
possible	O
.	O
</s>
<s>
Most	O
standard	O
techniques	O
treat	O
color	B-Algorithm
quantization	I-Algorithm
as	O
a	O
problem	O
of	O
clustering	O
points	O
in	O
three-dimensional	O
space	O
,	O
where	O
the	O
points	O
represent	O
colors	O
found	O
in	O
the	O
original	O
image	O
and	O
the	O
three	O
axes	O
represent	O
the	O
three	O
color	O
channels	O
.	O
</s>
<s>
Almost	O
any	O
three-dimensional	O
clustering	B-Algorithm
algorithm	I-Algorithm
can	O
be	O
applied	O
to	O
color	B-Algorithm
quantization	I-Algorithm
,	O
and	O
vice	O
versa	O
.	O
</s>
<s>
The	O
three	O
color	O
channels	O
are	O
usually	O
red	O
,	O
green	O
,	O
and	O
blue	O
,	O
but	O
another	O
popular	O
choice	O
is	O
the	O
Lab	O
color	B-Algorithm
space	I-Algorithm
,	O
in	O
which	O
Euclidean	O
distance	O
is	O
more	O
consistent	O
with	O
perceptual	O
difference	O
.	O
</s>
<s>
The	O
most	O
popular	O
algorithm	O
by	O
far	O
for	O
color	B-Algorithm
quantization	I-Algorithm
,	O
invented	O
by	O
Paul	O
Heckbert	O
in	O
1979	O
,	O
is	O
the	O
median	B-Algorithm
cut	I-Algorithm
algorithm	O
.	O
</s>
<s>
Before	O
this	O
time	O
,	O
most	O
color	B-Algorithm
quantization	I-Algorithm
was	O
done	O
using	O
the	O
population	O
algorithm	O
or	O
population	O
method	O
,	O
which	O
essentially	O
constructs	O
a	O
histogram	O
of	O
equal-sized	O
ranges	O
and	O
assigns	O
colors	O
to	O
the	O
ranges	O
containing	O
the	O
most	O
points	O
.	O
</s>
<s>
A	O
more	O
modern	O
popular	O
method	O
is	O
clustering	O
using	O
octrees	B-Data_Structure
,	O
first	O
conceived	O
by	O
Gervautz	O
and	O
Purgathofer	O
and	O
improved	O
by	O
Xerox	O
PARC	O
researcher	O
Dan	O
Bloomberg	O
.	O
</s>
<s>
This	O
means	O
all	O
of	O
its	O
pixel	O
colors	O
lie	O
in	O
a	O
two-dimensional	O
plane	O
in	O
the	O
color	O
cube.thumb	O
|left|300px|The	O
color	B-Algorithm
space	I-Algorithm
of	O
the	O
photograph	O
to	O
the	O
left	O
,	O
along	O
with	O
a	O
16-color	O
optimized	O
palette	B-Data_Structure
produced	O
by	O
Photoshop	B-Operating_System
.	O
</s>
<s>
The	O
Voronoi	O
regions	O
of	O
each	O
palette	B-Data_Structure
entry	I-Data_Structure
are	O
shown	O
.	O
</s>
<s>
If	O
the	O
palette	B-Data_Structure
is	O
fixed	O
,	O
as	O
is	O
often	O
the	O
case	O
in	O
real-time	O
color	B-Algorithm
quantization	I-Algorithm
systems	O
such	O
as	O
those	O
used	O
in	O
operating	O
systems	O
,	O
color	B-Algorithm
quantization	I-Algorithm
is	O
usually	O
done	O
using	O
the	O
"	O
straight-line	O
distance	O
"	O
or	O
"	O
nearest	O
color	O
"	O
algorithm	O
,	O
which	O
simply	O
takes	O
each	O
color	O
in	O
the	O
original	O
image	O
and	O
finds	O
the	O
closest	O
palette	B-Data_Structure
entry	I-Data_Structure
,	O
where	O
distance	O
is	O
determined	O
by	O
the	O
distance	O
between	O
the	O
two	O
corresponding	O
points	O
in	O
three-dimensional	O
space	O
.	O
</s>
<s>
This	O
effectively	O
decomposes	O
the	O
color	O
cube	O
into	O
a	O
Voronoi	B-Architecture
diagram	I-Architecture
,	O
where	O
the	O
palette	B-Data_Structure
entries	I-Data_Structure
are	O
the	O
points	O
and	O
a	O
cell	O
contains	O
all	O
colors	O
mapping	O
to	O
a	O
single	O
palette	B-Data_Structure
entry	I-Data_Structure
.	O
</s>
<s>
There	O
are	O
efficient	O
algorithms	O
from	O
computational	O
geometry	O
for	O
computing	O
Voronoi	B-Architecture
diagrams	I-Architecture
and	O
determining	O
which	O
region	O
a	O
given	O
point	O
falls	O
in	O
;	O
in	O
practice	O
,	O
indexed	B-Data_Structure
palettes	I-Data_Structure
are	O
so	O
small	O
that	O
these	O
are	O
usually	O
overkill	O
.	O
</s>
<s>
Color	B-Algorithm
quantization	I-Algorithm
is	O
frequently	O
combined	O
with	O
dithering	O
,	O
which	O
can	O
eliminate	O
unpleasant	O
artifacts	O
such	O
as	O
banding	O
that	O
appear	O
when	O
quantizing	O
smooth	O
gradients	O
and	O
give	O
the	O
appearance	O
of	O
a	O
larger	O
number	O
of	O
colors	O
.	O
</s>
<s>
Some	O
modern	O
schemes	O
for	O
color	B-Algorithm
quantization	I-Algorithm
attempt	O
to	O
combine	O
palette	B-Data_Structure
selection	O
with	O
dithering	O
in	O
one	O
stage	O
,	O
rather	O
than	O
perform	O
them	O
independently	O
.	O
</s>
<s>
The	O
Local	O
K-means	B-Algorithm
algorithm	I-Algorithm
,	O
conceived	O
by	O
Oleg	O
Verevka	O
in	O
1995	O
,	O
is	O
designed	O
for	O
use	O
in	O
windowing	O
systems	O
where	O
a	O
core	O
set	O
of	O
"	O
reserved	O
colors	O
"	O
is	O
fixed	O
for	O
use	O
by	O
the	O
system	O
and	O
many	O
images	O
with	O
different	O
color	O
schemes	O
might	O
be	O
displayed	O
simultaneously	O
.	O
</s>
<s>
It	O
is	O
a	O
post-clustering	O
scheme	O
that	O
makes	O
an	O
initial	O
guess	O
at	O
the	O
palette	B-Data_Structure
and	O
then	O
iteratively	O
refines	O
it	O
.	O
</s>
<s>
In	O
the	O
early	O
days	O
of	O
color	B-Algorithm
quantization	I-Algorithm
,	O
the	O
k-means	B-Algorithm
clustering	I-Algorithm
algorithm	I-Algorithm
was	O
deemed	O
unsuitable	O
because	O
of	O
its	O
high	O
computational	O
requirements	O
and	O
sensitivity	O
to	O
initialization	O
.	O
</s>
<s>
In	O
2011	O
,	O
M	O
.	O
Emre	O
Celebi	O
reinvestigated	O
the	O
performance	O
of	O
k-means	B-Algorithm
as	O
a	O
color	O
quantizer	O
.	O
</s>
<s>
He	O
demonstrated	O
that	O
an	O
efficient	O
implementation	O
of	O
k-means	B-Algorithm
outperforms	O
a	O
large	O
number	O
of	O
color	B-Algorithm
quantization	I-Algorithm
methods	O
.	O
</s>
<s>
The	O
high-quality	O
but	O
slow	O
NeuQuant	O
algorithm	O
reduces	O
images	O
to	O
256	O
colors	O
by	O
training	O
a	O
Kohonen	B-Algorithm
neural	I-Algorithm
network	I-Algorithm
"	O
which	O
self-organises	O
through	O
learning	O
to	O
match	O
the	O
distribution	O
of	O
colours	O
in	O
an	O
input	O
image	O
.	O
</s>
<s>
Finally	O
,	O
one	O
of	O
the	O
newer	O
methods	O
is	O
spatial	O
color	B-Algorithm
quantization	I-Algorithm
,	O
conceived	O
by	O
Puzicha	O
,	O
Held	O
,	O
Ketterer	O
,	O
Buhmann	O
,	O
and	O
Fellner	O
of	O
the	O
University	O
of	O
Bonn	O
,	O
which	O
combines	O
dithering	O
with	O
palette	B-Data_Structure
generation	O
and	O
a	O
simplified	O
model	O
of	O
human	O
perception	O
to	O
produce	O
visually	O
impressive	O
results	O
even	O
for	O
very	O
small	O
numbers	O
of	O
colors	O
.	O
</s>
<s>
It	O
does	O
not	O
treat	O
palette	B-Data_Structure
selection	O
strictly	O
as	O
a	O
clustering	O
problem	O
,	O
in	O
that	O
the	O
colors	O
of	O
nearby	O
pixels	O
in	O
the	O
original	O
image	O
also	O
affect	O
the	O
color	O
of	O
a	O
pixel	O
.	O
</s>
<s>
Color	B-Algorithm
quantization	I-Algorithm
helped	O
to	O
justify	O
this	O
tradeoff	O
by	O
making	O
it	O
possible	O
to	O
display	O
many	O
high	O
color	O
images	O
in	O
16	O
-	O
and	O
256-color	O
modes	O
with	O
limited	O
visual	O
degradation	O
.	O
</s>
<s>
Many	O
operating	O
systems	O
automatically	O
perform	O
quantization	B-Algorithm
and	O
dithering	O
when	O
viewing	O
high	O
color	O
images	O
in	O
a	O
256	O
color	O
video	O
mode	O
,	O
which	O
was	O
important	O
when	O
video	O
devices	O
limited	O
to	O
256	O
color	O
modes	O
were	O
dominant	O
.	O
</s>
<s>
Nowadays	O
,	O
color	B-Algorithm
quantization	I-Algorithm
is	O
mainly	O
used	O
in	O
GIF	O
and	O
PNG	O
images	O
.	O
</s>
<s>
GIF	O
,	O
for	O
a	O
long	O
time	O
the	O
most	O
popular	O
lossless	O
and	O
animated	O
bitmap	O
format	O
on	O
the	O
World	O
Wide	O
Web	O
,	O
only	O
supports	O
up	O
to	O
256	O
colors	O
,	O
necessitating	O
quantization	B-Algorithm
for	O
many	O
images	O
.	O
</s>
<s>
Some	O
early	O
web	O
browsers	O
constrained	O
images	O
to	O
use	O
a	O
specific	O
palette	B-Data_Structure
known	O
as	O
the	O
web	O
colors	O
,	O
leading	O
to	O
severe	O
degradation	O
in	O
quality	O
compared	O
to	O
optimized	O
palettes	B-Data_Structure
.	O
</s>
<s>
PNG	O
images	O
support	O
24-bit	O
color	O
,	O
but	O
can	O
often	O
be	O
made	O
much	O
smaller	O
in	O
filesize	O
without	O
much	O
visual	O
degradation	O
by	O
application	O
of	O
color	B-Algorithm
quantization	I-Algorithm
,	O
since	O
PNG	O
files	O
use	O
fewer	O
bits	O
per	O
pixel	O
for	O
palettized	O
images	O
.	O
</s>
<s>
The	O
infinite	O
number	O
of	O
colors	O
available	O
through	O
the	O
lens	O
of	O
a	O
camera	O
is	O
impossible	O
to	O
display	O
on	O
a	O
computer	O
screen	O
;	O
thus	O
converting	O
any	O
photograph	O
to	O
a	O
digital	O
representation	O
necessarily	O
involves	O
some	O
quantization	B-Algorithm
.	O
</s>
<s>
Practically	O
speaking	O
,	O
24-bit	O
color	O
is	O
sufficiently	O
rich	O
to	O
represent	O
almost	O
all	O
colors	O
perceivable	O
by	O
humans	O
with	O
sufficiently	O
small	O
error	O
as	O
to	O
be	O
visually	O
identical	O
(	O
if	O
presented	O
faithfully	O
)	O
,	O
within	O
the	O
available	O
color	B-Algorithm
space	I-Algorithm
.	O
</s>
<s>
However	O
,	O
the	O
digitization	O
of	O
color	O
,	O
either	O
in	O
a	O
camera	O
detector	O
or	O
on	O
a	O
screen	O
,	O
necessarily	O
limits	O
the	O
available	O
color	B-Algorithm
space	I-Algorithm
.	O
</s>
<s>
For	O
example	O
,	O
it	O
is	O
impossible	O
in	O
typical	O
RGB	O
color	B-Algorithm
spaces	I-Algorithm
(	O
common	O
on	O
computer	O
monitors	O
)	O
to	O
reproduce	O
the	O
full	O
range	O
of	O
green	O
colors	O
that	O
the	O
human	O
eye	O
is	O
capable	O
of	O
perceiving	O
.	O
</s>
<s>
With	O
the	O
few	O
colors	O
available	O
on	O
early	O
computers	O
,	O
different	O
quantization	B-Algorithm
algorithms	O
produced	O
very	O
different-looking	O
output	O
images	O
.	O
</s>
<s>
Many	O
image	O
file	O
formats	O
support	O
indexed	B-Data_Structure
color	I-Data_Structure
.	O
</s>
<s>
A	O
whole-image	O
palette	B-Data_Structure
typically	O
selects	O
256	O
"	O
representative	O
"	O
colors	O
for	O
the	O
entire	O
image	O
,	O
where	O
each	O
pixel	O
references	O
any	O
one	O
of	O
the	O
colors	O
in	O
the	O
palette	B-Data_Structure
,	O
as	O
in	O
the	O
GIF	O
and	O
PNG	O
file	O
formats	O
.	O
</s>
<s>
A	O
block	O
palette	B-Data_Structure
typically	O
selects	O
2	O
or	O
4	O
colors	O
for	O
each	O
block	O
of	O
4x4	O
pixels	O
,	O
used	O
in	O
BTC	O
,	O
CCC	O
,	O
S2TC	B-Algorithm
,	O
and	O
S3TC	O
.	O
</s>
<s>
Many	O
bitmap	B-Application
graphics	I-Application
editors	I-Application
contain	O
built-in	O
support	O
for	O
color	B-Algorithm
quantization	I-Algorithm
,	O
and	O
will	O
automatically	O
perform	O
it	O
when	O
converting	O
an	O
image	O
with	O
many	O
colors	O
to	O
an	O
image	O
format	O
with	O
fewer	O
colors	O
.	O
</s>
<s>
Photoshop	B-Operating_System
's	O
Mode	O
→	O
Indexed	B-Data_Structure
Color	I-Data_Structure
function	O
supplies	O
a	O
number	O
of	O
quantization	B-Algorithm
algorithms	O
ranging	O
from	O
the	O
fixed	O
Windows	O
system	O
and	O
Web	O
palettes	B-Data_Structure
to	O
the	O
proprietary	O
Local	O
and	O
Global	O
algorithms	O
for	O
generating	O
palettes	B-Data_Structure
suited	O
to	O
a	O
particular	O
image	O
or	O
images	O
.	O
</s>
<s>
Paint	O
Shop	O
Pro	O
,	O
in	O
its	O
Colors	O
→	O
Decrease	O
Color	O
Depth	O
dialog	O
,	O
supplies	O
three	O
standard	O
color	B-Algorithm
quantization	I-Algorithm
algorithms	O
:	O
median	B-Algorithm
cut	I-Algorithm
,	O
octree	B-Data_Structure
,	O
and	O
the	O
fixed	O
standard	O
"	O
web	O
safe	O
"	O
palette	B-Data_Structure
.	O
</s>
<s>
In	O
GIMP	O
2.8	O
,	O
the	O
Convert	O
Image	O
to	O
Indexed	B-Data_Structure
Colors	I-Data_Structure
Option	O
(	O
Image	O
→	O
Mode	O
→	O
Indexed	O
..	O
)	O
allows	O
generation	O
of	O
an	O
optimum	O
palette	B-Data_Structure
with	O
a	O
choice	O
in	O
the	O
number	O
of	O
colors	O
from	O
2	O
to	O
256	O
,	O
the	O
option	O
of	O
using	O
a	O
web-optimized	O
palette	B-Data_Structure
,	O
using	O
a	O
black	O
and	O
white	O
palette	B-Data_Structure
(	O
1	O
bit	O
)	O
or	O
using	O
a	O
custom	O
palette	B-Data_Structure
.	O
</s>
<s>
It	O
allows	O
unused	O
colors	O
to	O
be	O
removed	O
from	O
the	O
palette	B-Data_Structure
and	O
it	O
offers	O
a	O
variety	O
of	O
dithering	O
options	O
:	O
None	O
,	O
Floyd-Steinberg	O
(	O
normal	O
)	O
,	O
Floyd-Steinberg	O
(	O
reduced	O
color	O
bleeding	O
)	O
and	O
Positioned	O
as	O
well	O
as	O
the	O
ability	O
to	O
enable	O
dithering	O
of	O
transparency	O
.	O
</s>
<s>
Color	B-Algorithm
quantization	I-Algorithm
is	O
also	O
used	O
to	O
create	O
posterization	B-Algorithm
effects	O
,	O
although	O
posterization	B-Algorithm
has	O
the	O
slightly	O
different	O
goal	O
of	O
minimizing	O
the	O
number	O
of	O
colors	O
used	O
within	O
the	O
same	O
color	B-Algorithm
space	I-Algorithm
,	O
and	O
typically	O
uses	O
a	O
fixed	O
palette	B-Data_Structure
.	O
</s>
<s>
Some	O
vector	B-Application
graphics	I-Application
editors	I-Application
also	O
utilize	O
color	B-Algorithm
quantization	I-Algorithm
,	O
especially	O
for	O
raster-to-vector	O
techniques	O
that	O
create	O
tracings	O
of	O
bitmap	O
images	O
with	O
the	O
help	O
of	O
edge	B-Algorithm
detection	I-Algorithm
.	O
</s>
<s>
Inkscape	O
's	O
Path	O
→	O
Trace	O
Bitmap	O
:	O
Multiple	O
Scans	O
:	O
Color	O
function	O
uses	O
octree	B-Data_Structure
quantization	B-Algorithm
to	O
create	O
color	O
traces	O
.	O
</s>
