<s>
Color	B-Algorithm
Cell	I-Algorithm
Compression	I-Algorithm
is	O
a	O
lossy	B-Algorithm
image	B-General_Concept
compression	I-General_Concept
algorithm	O
developed	O
by	O
Campbell	O
et	O
al.	O
,	O
in	O
1986	O
,	O
which	O
can	O
be	O
considered	O
an	O
early	O
forerunner	O
of	O
modern	O
texture	O
compression	O
algorithms	O
,	O
such	O
as	O
S3	O
Texture	O
Compression	O
and	O
Adaptive	O
Scalable	O
Texture	O
Compression	O
.	O
</s>
<s>
It	O
is	O
closely	O
related	O
to	O
Block	B-Algorithm
Truncation	I-Algorithm
Coding	I-Algorithm
,	O
another	O
lossy	B-Algorithm
image	B-General_Concept
compression	I-General_Concept
algorithm	O
,	O
which	O
predates	O
Color	B-Algorithm
Cell	I-Algorithm
Compression	I-Algorithm
,	O
in	O
that	O
it	O
uses	O
the	O
dominant	O
luminance	O
of	O
a	O
block	O
of	O
pixels	B-Algorithm
to	O
partition	O
said	O
pixels	B-Algorithm
into	O
two	O
representative	O
colors	O
.	O
</s>
<s>
The	O
primary	O
difference	O
between	O
Block	B-Algorithm
Truncation	I-Algorithm
Coding	I-Algorithm
and	O
Color	B-Algorithm
Cell	I-Algorithm
Compression	I-Algorithm
is	O
that	O
the	O
former	O
was	O
designed	O
to	O
compress	O
grayscale	O
images	O
and	O
the	O
latter	O
was	O
designed	O
to	O
compress	O
color	O
images	O
.	O
</s>
<s>
Also	O
,	O
Block	B-Algorithm
Truncation	I-Algorithm
Coding	I-Algorithm
requires	O
that	O
the	O
standard	B-General_Concept
deviation	I-General_Concept
of	O
the	O
colors	O
of	O
pixels	B-Algorithm
in	O
a	O
block	O
be	O
computed	O
in	O
order	O
to	O
compress	O
an	O
image	O
,	O
whereas	O
Color	B-Algorithm
Cell	I-Algorithm
Compression	I-Algorithm
does	O
not	O
use	O
the	O
standard	B-General_Concept
deviation	I-General_Concept
.	O
</s>
<s>
Both	O
algorithms	O
,	O
though	O
,	O
can	O
compress	O
an	O
image	O
down	O
to	O
effectively	O
2	O
bits	O
per	O
pixel	B-Algorithm
.	O
</s>
<s>
The	O
Color	B-Algorithm
Cell	I-Algorithm
Compression	I-Algorithm
algorithm	O
processes	O
an	O
image	O
in	O
eight	O
steps	O
,	O
although	O
one	O
of	O
the	O
steps	O
(	O
step	O
#6	O
)	O
is	O
optional	O
.	O
</s>
<s>
It	O
is	O
assumed	O
here	O
that	O
the	O
input	O
is	O
a	O
24	O
bits/pixel	O
image	O
,	O
as	O
assumed	O
in	O
the	O
original	O
journal	O
article	O
,	O
although	O
other	O
bit	O
depths	O
could	O
be	O
used	O
.	O
</s>
<s>
The	O
image	O
is	O
now	O
subdivided	O
into	O
4-pixel	O
by	O
4-pixel	O
blocks	O
,	O
and	O
,	O
the	O
arithmetic	O
mean	O
of	O
the	O
luminance	O
of	O
each	O
pixel	B-Algorithm
in	O
the	O
block	O
is	O
used	O
to	O
select	O
a	O
representative	O
luminance	O
value	O
.	O
</s>
<s>
Each	O
block	O
of	O
pixels	B-Algorithm
is	O
then	O
divided	O
into	O
two	O
groups	O
.	O
</s>
<s>
One	O
group	O
consists	O
of	O
pixels	B-Algorithm
in	O
the	O
current	O
block	O
where	O
each	O
pixel	B-Algorithm
's	O
luminance	O
is	O
greater	O
than	O
or	O
equal	O
to	O
the	O
representative	O
luminance	O
for	O
the	O
current	O
block	O
.	O
</s>
<s>
The	O
second	O
group	O
of	O
pixels	B-Algorithm
consists	O
of	O
pixels	B-Algorithm
in	O
the	O
current	O
block	O
where	O
each	O
pixel	B-Algorithm
's	O
luminance	O
is	O
less	O
than	O
the	O
representative	O
luminance	O
for	O
the	O
current	O
block	O
.	O
</s>
<s>
Whether	O
a	O
pixel	B-Algorithm
in	O
the	O
current	O
block	O
belongs	O
to	O
a	O
certain	O
group	O
is	O
determined	O
by	O
a	O
binary	O
"	O
0	O
"	O
or	O
a	O
"	O
1	O
"	O
value	O
in	O
another	O
,	O
separate	O
,	O
16-entry	O
bitmap	O
.	O
</s>
<s>
Two	O
representative	O
24-bit	O
colors	O
are	O
now	O
selected	O
for	O
each	O
block	O
of	O
pixels	B-Algorithm
by	O
computing	O
two	O
arithmetic	O
means	O
.	O
</s>
<s>
The	O
first	O
arithmetic	O
mean	O
is	O
the	O
arithmetic	O
mean	O
of	O
all	O
of	O
the	O
pixels	B-Algorithm
belonging	O
to	O
the	O
first	O
group	O
of	O
pixels	B-Algorithm
where	O
the	O
luminance	O
of	O
each	O
pixel	B-Algorithm
is	O
a	O
"	O
1	O
"	O
in	O
the	O
luminance	O
bitmap	O
.	O
</s>
<s>
The	O
second	O
24-bit	O
representative	O
color	O
is	O
selected	O
similarly	O
,	O
by	O
taking	O
the	O
arithmetic	O
mean	O
of	O
all	O
the	O
24-bit	O
color	O
pixels	B-Algorithm
in	O
the	O
second	O
group	O
where	O
each	O
pixel	B-Algorithm
corresponds	O
to	O
a	O
"	O
0	O
"	O
in	O
the	O
luminance	O
bitmap	O
.	O
</s>
<s>
The	O
total	O
size	O
of	O
the	O
compressed	O
block	O
is	O
now	O
16	O
bits	O
for	O
the	O
luminance	O
bitmap	O
,	O
and	O
two	O
24-bit	O
binary	O
quantities	O
for	O
each	O
representative	O
color	O
,	O
yielding	O
a	O
total	O
size	O
of	O
64	O
bits	O
,	O
which	O
,	O
when	O
divided	O
by	O
16	O
(	O
the	O
number	O
of	O
pixels	B-Algorithm
in	O
the	O
block	O
)	O
,	O
yields	O
4	O
i.e.	O
</s>
<s>
4	O
bits	O
per	O
pixel	B-Algorithm
.	O
</s>
<s>
Each	O
compressed	O
block	O
of	O
pixels	B-Algorithm
is	O
modified	O
by	O
truncating	B-Language
each	O
of	O
the	O
two	O
24-bit	O
representative	O
colors	O
to	O
15	O
bits	O
.	O
</s>
<s>
This	O
step	O
is	O
optional	O
,	O
and	O
the	O
algorithm	O
can	O
terminate	O
at	O
this	O
point	O
,	O
if	O
desired	O
,	O
as	O
the	O
compressed	O
blocks	O
at	O
this	O
stage	O
have	O
a	O
total	O
size	O
of	O
bits	O
,	O
which	O
,	O
when	O
divided	O
by	O
16	O
,	O
yields	O
2.875	O
bits	O
per	O
pixel	B-Algorithm
.	O
</s>
<s>
Also	O
,	O
since	O
each	O
15-bit	O
binary	O
color	O
vector	O
is	O
presumably	O
stored	O
in	O
a	O
16-bit	O
word	O
,	O
then	O
the	O
16th	O
bit	O
can	O
be	O
used	O
to	O
improve	O
the	O
image	O
quality	O
by	O
specifying	O
which	O
one	O
of	O
two	O
lookup	B-Data_Structure
tables	I-Data_Structure
should	O
be	O
used	O
.	O
</s>
<s>
In	O
a	O
naïve	O
implementation	O
,	O
the	O
histogram	O
is	O
consulted	O
to	O
choose	O
256	O
of	O
the	O
most	O
frequently	O
used	O
colors	O
which	O
are	O
then	O
put	O
into	O
a	O
256-entry	O
array	O
,	O
where	O
each	O
entry	O
consists	O
of	O
three	O
octets	O
of	O
a	O
24-bit	O
per	O
pixel	B-Algorithm
color	O
value	O
.	O
</s>
<s>
The	O
histogram	O
method	O
of	O
selecting	O
the	O
most	O
appropriate	O
colors	O
for	O
the	O
original	O
24-bit	O
per	O
pixel	B-Algorithm
color	O
image	O
can	O
instead	O
be	O
replaced	O
by	O
a	O
vector	O
quantization	O
class	O
algorithm	O
such	O
as	O
the	O
median	B-Algorithm
cut	I-Algorithm
algorithm	O
or	O
K-means	B-Algorithm
clustering	I-Algorithm
which	O
usually	O
yields	O
better	O
results	O
.	O
</s>
<s>
The	O
final	O
step	O
consists	O
of	O
taking	O
the	O
current	O
block	O
of	O
pixels	B-Algorithm
and	O
determining	O
which	O
24-bit	O
per	O
pixel	B-Algorithm
color	O
in	O
the	O
256-entry	O
lookup	B-Data_Structure
table	I-Data_Structure
most	O
closely	O
match	O
the	O
two	O
representative	O
colors	O
for	O
each	O
block	O
.	O
</s>
<s>
The	O
two	O
8-bit	O
indices	O
pointing	O
to	O
colors	O
in	O
the	O
lookup	B-Data_Structure
table	I-Data_Structure
are	O
now	O
appended	O
to	O
the	O
16-bit	O
luminance	O
bitmap	O
.	O
</s>
<s>
This	O
yields	O
a	O
total	O
compressed	O
size	O
of	O
bits	O
,	O
which	O
,	O
when	O
divided	O
by	O
16	O
,	O
yields	O
2	O
bits	O
per	O
pixel	B-Algorithm
.	O
</s>
<s>
To	O
reconstruct	O
each	O
compressed	O
4-pixel	O
by	O
4-pixel	O
block	O
,	O
the	O
16-bit	O
luminance	O
bitmap	O
is	O
consulted	O
for	O
each	O
block	O
.	O
</s>
<s>
Depending	O
on	O
whether	O
an	O
element	O
of	O
the	O
bitmap	O
is	O
1	O
or	O
0	O
,	O
one	O
of	O
the	O
two	O
8-bit	O
indices	O
into	O
the	O
lookup	B-Data_Structure
table	I-Data_Structure
is	O
selected	O
and	O
then	O
dereferenced	O
and	O
the	O
corresponding	O
24-bit	O
per	O
pixel	B-Algorithm
color	O
value	O
is	O
retrieved	O
.	O
</s>
<s>
Although	O
far	O
surpassed	O
in	O
compression	B-General_Concept
ratio	I-General_Concept
by	O
later	O
block-transform	O
coding	O
methods	O
such	O
as	O
JPEG	O
,	O
it	O
has	O
the	O
advantage	O
of	O
very	O
simple	O
decompression	O
and	O
fast	O
random	O
access	O
into	O
the	O
compressed	B-General_Concept
image	I-General_Concept
.	O
</s>
<s>
Apple	B-Algorithm
Video	I-Algorithm
(	O
RPZA	B-Algorithm
)	O
and	O
S3	O
Texture	O
Compression	O
employ	O
the	O
same	O
principle	O
of	O
encoding	O
4×	O
4-pixel	O
blocks	O
based	O
on	O
two	O
representative	O
colors	O
.	O
</s>
<s>
To	O
work	O
around	O
S3	O
's	O
patent	O
,	O
the	O
Super	O
Simple	O
Texture	O
Compression	O
(	O
S2TC	B-Algorithm
)	O
library	O
was	O
created	O
to	O
encode	O
CCC	O
data	O
in	O
a	O
format	O
compatible	O
with	O
S3TC	O
decoders	O
and	O
to	O
reinterpret	O
S3TC	O
as	O
CCC	O
with	O
minor	O
quality	O
loss	O
.	O
</s>
