<s>
In	O
computer	O
graphics	O
,	O
alpha	B-Algorithm
compositing	I-Algorithm
or	O
alpha	B-Algorithm
blending	I-Algorithm
is	O
the	O
process	O
of	O
combining	O
one	O
image	O
with	O
a	O
background	O
to	O
create	O
the	O
appearance	O
of	O
partial	O
or	O
full	O
transparency	O
.	O
</s>
<s>
It	O
is	O
often	O
useful	O
to	O
render	O
picture	B-Algorithm
elements	I-Algorithm
(	O
pixels	B-Algorithm
)	O
in	O
separate	O
passes	O
or	O
layers	O
and	O
then	O
combine	O
the	O
resulting	O
2D	O
images	O
into	O
a	O
single	O
,	O
final	O
image	O
called	O
the	O
composite	O
.	O
</s>
<s>
Alpha	B-Algorithm
blending	I-Algorithm
is	O
also	O
used	O
in	O
2D	O
computer	O
graphics	O
to	O
put	O
rasterized	O
foreground	O
elements	O
over	O
a	O
background	O
.	O
</s>
<s>
In	O
order	O
to	O
combine	O
the	O
picture	B-Algorithm
elements	I-Algorithm
of	O
the	O
images	O
correctly	O
,	O
it	O
is	O
necessary	O
to	O
keep	O
an	O
associated	O
matte	O
for	O
each	O
element	O
in	O
addition	O
to	O
its	O
color	O
.	O
</s>
<s>
Although	O
the	O
most	O
basic	O
operation	O
of	O
combining	O
two	O
images	O
is	O
to	O
put	O
one	O
over	O
the	O
other	O
,	O
there	O
are	O
many	O
operations	O
,	O
or	O
blend	B-Algorithm
modes	I-Algorithm
,	O
that	O
are	O
used	O
.	O
</s>
<s>
In	O
a	O
2D	O
image	O
a	O
color	O
combination	O
is	O
stored	O
for	O
each	O
picture	B-Algorithm
element	I-Algorithm
(	O
pixel	B-Algorithm
)	O
,	O
often	O
a	O
combination	O
of	O
red	O
,	O
green	O
and	O
blue	O
(	O
RGB	O
)	O
.	O
</s>
<s>
When	O
alpha	B-Algorithm
compositing	I-Algorithm
is	O
in	O
use	O
,	O
each	O
pixel	B-Algorithm
has	O
an	O
additional	O
numeric	O
value	O
stored	O
in	O
its	O
alpha	B-Algorithm
channel	I-Algorithm
,	O
with	O
a	O
value	O
ranging	O
from	O
0	O
to	O
1	O
.	O
</s>
<s>
A	O
value	O
of	O
0	O
means	O
that	O
the	O
pixel	B-Algorithm
is	O
fully	O
transparent	O
and	O
the	O
color	O
in	O
the	O
pixel	B-Algorithm
beneath	O
will	O
show	O
through	O
.	O
</s>
<s>
A	O
value	O
of	O
1	O
means	O
that	O
the	O
pixel	B-Algorithm
is	O
fully	O
opaque	O
.	O
</s>
<s>
With	O
the	O
existence	O
of	O
an	O
alpha	B-Algorithm
channel	I-Algorithm
,	O
it	O
is	O
possible	O
to	O
express	O
compositing	O
image	O
operations	O
using	O
a	O
compositing	O
algebra	O
.	O
</s>
<s>
In	O
addition	O
to	O
over	O
,	O
Porter	O
and	O
Duff	O
defined	O
the	O
compositing	O
operators	O
in	O
,	O
held	O
out	O
by	O
(	O
the	O
phrase	O
refers	O
to	O
holdout	O
matting	O
and	O
is	O
usually	O
abbreviated	O
out	O
)	O
,	O
atop	O
,	O
and	O
xor	O
(	O
and	O
the	O
reverse	O
operators	O
rover	O
,	O
rin	O
,	O
rout	O
,	O
and	O
ratop	O
)	O
from	O
a	O
consideration	O
of	O
choices	O
in	O
blending	O
the	O
colors	O
of	O
two	O
pixels	B-Algorithm
when	O
their	O
coverage	O
is	O
,	O
conceptually	O
,	O
overlaid	O
orthogonally	O
:	O
</s>
<s>
As	O
an	O
example	O
,	O
the	O
over	O
operator	O
can	O
be	O
accomplished	O
by	O
applying	O
the	O
following	O
formula	O
to	O
each	O
pixel	B-Algorithm
:	O
</s>
<s>
Here	O
,	O
and	O
stand	O
for	O
the	O
color	O
components	O
of	O
the	O
pixels	B-Algorithm
in	O
the	O
result	O
,	O
image	O
A	O
and	O
image	O
B	O
respectively	O
,	O
applied	O
to	O
each	O
color	O
channel	O
(	O
red/green/blue	O
)	O
individually	O
,	O
whereas	O
,	O
and	O
are	O
the	O
alpha	O
values	O
of	O
the	O
respective	O
pixels	B-Algorithm
.	O
</s>
<s>
The	O
over	O
operator	O
is	O
,	O
in	O
effect	O
,	O
the	O
normal	O
painting	O
operation	O
(	O
see	O
Painter	B-Algorithm
's	I-Algorithm
algorithm	I-Algorithm
)	O
.	O
</s>
<s>
The	O
in	O
and	O
out	O
operators	O
are	O
the	O
alpha	B-Algorithm
compositing	I-Algorithm
equivalent	O
of	O
clipping	O
.	O
</s>
<s>
The	O
two	O
use	O
only	O
the	O
alpha	B-Algorithm
channel	I-Algorithm
of	O
the	O
second	O
image	O
and	O
ignore	O
the	O
color	O
components	O
.	O
</s>
<s>
If	O
an	O
alpha	B-Algorithm
channel	I-Algorithm
is	O
used	O
in	O
an	O
image	O
,	O
there	O
are	O
two	O
common	O
representations	O
that	O
are	O
available	O
:	O
straight	O
(	O
unassociated	O
)	O
alpha	O
and	O
premultiplied	O
(	O
associated	O
)	O
alpha	O
.	O
</s>
<s>
With	O
straight	O
alpha	O
,	O
the	O
RGB	O
components	O
represent	O
the	O
color	O
of	O
the	O
object	O
or	O
pixel	B-Algorithm
,	O
disregarding	O
its	O
opacity	O
.	O
</s>
<s>
With	O
premultiplied	B-Algorithm
alpha	I-Algorithm
,	O
the	O
RGB	O
components	O
represent	O
the	O
emission	O
of	O
the	O
object	O
or	O
pixel	B-Algorithm
,	O
and	O
the	O
alpha	O
represents	O
the	O
occlusion	O
.	O
</s>
<s>
The	O
most	O
significant	O
advantage	O
of	O
premultiplied	B-Algorithm
alpha	I-Algorithm
is	O
that	O
it	O
allows	O
for	O
correct	O
blending	O
,	O
interpolation	B-Algorithm
,	O
and	O
filtering	O
.	O
</s>
<s>
Ordinary	O
interpolation	B-Algorithm
without	O
premultiplied	B-Algorithm
alpha	I-Algorithm
leads	O
to	O
RGB	O
information	O
leaking	O
out	O
of	O
fully	O
transparent	O
(	O
A	O
=	O
0	O
)	O
regions	O
,	O
even	O
though	O
this	O
RGB	O
information	O
is	O
ideally	O
invisible	O
.	O
</s>
<s>
Errors	O
also	O
occur	O
in	O
areas	O
of	O
semitransparency	O
because	O
the	O
RGB	O
components	O
are	O
not	O
correctly	O
weighted	O
,	O
giving	O
incorrectly	O
high	O
weighting	O
to	O
the	O
color	O
of	O
the	O
more	O
transparent	O
(	O
lower	O
alpha	O
)	O
pixels	B-Algorithm
.	O
</s>
<s>
Premultiplied	B-Algorithm
alpha	I-Algorithm
may	O
also	O
be	O
used	O
to	O
allow	O
regions	O
of	O
regular	O
alpha	B-Algorithm
blending	I-Algorithm
and	O
regions	O
with	O
additive	B-Algorithm
blending	I-Algorithm
mode	I-Algorithm
to	O
be	O
encoded	O
within	O
the	O
same	O
image	O
.	O
</s>
<s>
Assuming	O
that	O
the	O
pixel	B-Algorithm
color	O
is	O
expressed	O
using	O
straight	O
(	O
non-premultiplied	O
)	O
RGBA	O
tuples	B-Application
,	O
a	O
pixel	B-Algorithm
value	O
of	O
(	O
0	O
,	O
0.7	O
,	O
0	O
,	O
0.5	O
)	O
implies	O
a	O
pixel	B-Algorithm
that	O
has	O
70%	O
of	O
the	O
maximum	O
green	O
intensity	O
and	O
50%	O
opacity	O
.	O
</s>
<s>
However	O
,	O
if	O
this	O
pixel	B-Algorithm
uses	O
premultiplied	B-Algorithm
alpha	I-Algorithm
,	O
all	O
of	O
the	O
RGB	O
values	O
(	O
0	O
,	O
0.7	O
,	O
0	O
)	O
are	O
multiplied	O
,	O
or	O
scaled	O
for	O
occlusion	O
,	O
by	O
the	O
alpha	O
value	O
0.5	O
,	O
which	O
is	O
appended	O
to	O
yield	O
(	O
0	O
,	O
0.35	O
,	O
0	O
,	O
0.5	O
)	O
.	O
</s>
<s>
Knowing	O
whether	O
a	O
file	O
uses	O
straight	O
or	O
premultiplied	B-Algorithm
alpha	I-Algorithm
is	O
essential	O
to	O
correctly	O
process	O
or	O
composite	O
it	O
,	O
as	O
a	O
different	O
calculation	O
is	O
required	O
.	O
</s>
<s>
Another	O
advantage	O
of	O
premultiplied	B-Algorithm
alpha	I-Algorithm
is	O
performance	O
;	O
in	O
certain	O
situations	O
,	O
it	O
can	O
reduce	O
the	O
number	O
of	O
multiplication	O
operations	O
(	O
e.g.	O
</s>
<s>
One	O
disadvantage	O
of	O
premultiplied	B-Algorithm
alpha	I-Algorithm
is	O
that	O
it	O
can	O
reduce	O
the	O
available	O
relative	O
precision	O
in	O
the	O
RGB	O
values	O
when	O
using	O
integer	O
or	O
fixed-point	O
representation	O
for	O
the	O
color	O
components	O
.	O
</s>
<s>
This	O
may	O
cause	O
a	O
noticeable	O
loss	O
of	O
quality	O
if	O
the	O
color	O
information	O
is	O
later	O
brightened	O
or	O
if	O
the	O
alpha	B-Algorithm
channel	I-Algorithm
is	O
removed	O
.	O
</s>
<s>
This	O
loss	O
of	O
precision	O
also	O
makes	O
premultiplied	O
images	O
easier	O
to	O
compress	B-General_Concept
using	O
certain	O
compression	O
schemes	O
,	O
as	O
they	O
do	O
not	O
record	O
the	O
color	O
variations	O
hidden	O
inside	O
transparent	O
regions	O
,	O
and	O
can	O
allocate	O
fewer	O
bits	O
to	O
encode	O
low-alpha	O
areas	O
.	O
</s>
<s>
When	O
combined	O
with	O
premultiplied	B-Algorithm
alpha	I-Algorithm
,	O
pre-multiplication	O
is	O
done	O
in	O
linear	O
space	O
,	O
prior	O
to	O
gamma	O
compression	O
.	O
</s>
<s>
Note	O
that	O
only	O
the	O
color	O
components	O
undergo	O
gamma-correction	O
;	O
the	O
alpha	B-Algorithm
channel	I-Algorithm
is	O
always	O
linear	O
.	O
</s>
<s>
Although	O
used	O
for	O
similar	O
purposes	O
,	O
transparent	O
colors	O
and	O
image	O
masks	O
do	O
not	O
permit	O
the	O
smooth	O
blending	O
of	O
the	O
superimposed	O
image	O
pixels	B-Algorithm
with	O
those	O
of	O
the	O
background	O
(	O
only	O
whole	O
image	O
pixels	B-Algorithm
or	O
whole	O
background	O
pixels	B-Algorithm
allowed	O
)	O
.	O
</s>
<s>
A	O
similar	O
effect	O
can	O
be	O
achieved	O
with	O
a	O
1-bit	O
alpha	B-Algorithm
channel	I-Algorithm
,	O
as	O
found	O
in	O
the	O
16-bit	O
RGBA	O
high	O
color	O
mode	O
of	O
the	O
Truevision	O
TGA	O
image	O
file	O
format	O
and	O
related	O
TARGA	O
and	O
AT-Vista/NU	O
-Vista	O
display	O
adapters	O
 '	O
high	O
color	O
graphic	O
mode	O
.	O
</s>
<s>
This	O
mode	O
devotes	O
5	O
bits	O
for	O
every	O
primary	O
RGB	O
color	O
(	O
15-bit	O
RGB	O
)	O
plus	O
a	O
remaining	O
bit	O
as	O
the	O
"	O
alpha	B-Algorithm
channel	I-Algorithm
"	O
.	O
</s>
<s>
For	O
some	O
applications	O
,	O
a	O
single	O
alpha	B-Algorithm
channel	I-Algorithm
is	O
not	O
sufficient	O
:	O
a	O
stained-glass	O
window	O
,	O
for	O
instance	O
,	O
requires	O
a	O
separate	O
transparency	O
channel	O
for	O
each	O
RGB	O
channel	O
to	O
model	O
the	O
red	O
,	O
green	O
and	O
blue	O
transparency	O
separately	O
.	O
</s>
<s>
More	O
alpha	B-Algorithm
channels	I-Algorithm
can	O
be	O
added	O
for	O
accurate	O
spectral	O
color	O
filtration	O
applications	O
.	O
</s>
<s>
The	O
concept	O
of	O
an	O
alpha	B-Algorithm
channel	I-Algorithm
was	O
introduced	O
by	O
Alvy	O
Ray	O
Smith	O
and	O
in	O
the	O
late	O
1970s	O
at	O
the	O
New	O
York	O
Institute	O
of	O
Technology	O
Computer	O
Graphics	O
Lab	O
,	O
and	O
fully	O
developed	O
in	O
a	O
1984	O
paper	O
by	O
Thomas	O
Porter	O
and	O
Tom	O
Duff	O
.	O
</s>
<s>
The	O
use	O
of	O
the	O
term	O
alpha	O
is	O
explained	O
by	O
Smith	O
as	O
follows	O
:	O
"	O
We	O
called	O
it	O
that	O
because	O
of	O
the	O
classic	O
linear	O
interpolation	B-Algorithm
formula	O
that	O
uses	O
the	O
Greek	O
letter	O
(	O
alpha	O
)	O
to	O
control	O
the	O
amount	O
of	O
interpolation	B-Algorithm
between	O
,	O
in	O
this	O
case	O
,	O
two	O
images	O
A	O
and	O
B	O
"	O
.	O
</s>
<s>
That	O
is	O
,	O
when	O
compositing	O
image	O
A	O
atop	O
image	O
B	O
,	O
the	O
value	O
of	O
in	O
the	O
formula	O
is	O
taken	O
directly	O
from	O
A	O
's	O
alpha	B-Algorithm
channel	I-Algorithm
.	O
</s>
