Digital Signal Processing Reference
In-Depth Information
7.3 Implementing Alpha Blending in
Hardware
Although it is simple in concept, implementing alpha blending
in real-time requires fast, dedicated hardware. Let's take a look at
the equation above
written in a short form here:
e
)
This means you need two multipliers and one adder. As imple-
menting a multiplier in hardware is expensive, you can rearrange
your equation as shown in Figure 7.1 to minimize the multipliers.
In Figure 7.1 :
Ci
p1i(
)
p2i(1
¼
a
þ
a
Composite pixel can be computed as:
c r = α f r + (1 − α) b r
c g = α f g + (1 − α) b g
c b = α f b + (1 − α) b b
This can also be written as:
One multiply
operation vs. two
c r = b r + α (f r − b r )
c g = b g + α (f g − b g )
c b = b b + α (f b − b b )
Figure 7.1. The equations for alpha blending.
C is the composite pixel value.
F is the foreground pixel
we were referring to it as the pixel
e
from frame one.
B is the background pixel
we were referring to it as the pixel
e
from frame two.
Figure 7.1 also illustrates that when we talk about creating
a composite pixel, the calculations have to be done separately for
each color component. We do the same calculation for red, green
and blue. Which means not two multipliers, but six multipliers for
one pixel
.
A simple rearrangement of the equation as shown lets us use
only one multiplier and two adders for each color component.
Which means three multipliers for the pixel
.
As adders are cheaper in silicon than multipliers this is the
route we would choose. Figure 7.2 shows the hardware required
to calculate the three color components of the composite pixel.
7.4 Creating a Different Background
It is common to see a background, behind a newscaster or
a weatherman for example, that is different to the actual physical
Search WWH ::




Custom Search