/  4
 
Efficient Anti-Aliasing Algorithm for
Computer
Generated Images
Tsuyoshi Isshiki and Hiroaki KuniedaDept. Electrical and Electronics EngineeringTokyo Institute
of
Technology2-12-1 Ookayama, Meguro-ku, Tokyo 152-8552,
JAPAN
Abstract
Anti-aliasing is one of the most important process forgenerating high quality
3D
graphics images. There havebeen many approaches for anti-aliasing but few considerthe real-time processing constraints which is critical forvarious interactive graphics applications. In this paper,we propose
a
very powerful but simple method for anti-aliasing called
double line scanning method
which is suit-able for low cost hardware implementation.
1
Introduction
Although the computational power of current micropro-cessors and
3D
graphics hardwares enable fast graphicsimage generation, there are strong demands for next gen-eration graphics platform which supports high qualityreal time graphics rendering. Anti-aliasing, especially,is one of the crucial task for such high quality graph-ics rendering which deals with the 'saggy edge" effect
of
computer generated images. Several methods on anti-aliasing are present to date
[l]
[2] [3] [4].
A popular
supersampling
approach generates the image
at
subpixelresolution and averages the color intensity on each pixelregion. The drawback of this approach is the high com-putational cost to generate the image
at
subpixel resolu-tion. Another approach is by
post-filtering
the generatedgraphics image
[3]
[4].
It estimates the shape of the ob-jects on the generated image, and calculates the pixelblending ratio on the edge pixels. The advantage
of
thisapproach is that the computational cost
is
significantlyless than other anti-aliasing approaches, and it can betotally isolated from other graphics rendering tasks.In this paper, we propose
a
new anti-aliasing methodcalled
double-line scanning method.
It is based on post-filtering approach which detects object edges on two linebuffers, estimates the edge slope and calculates the pixelblending ratio for the edge pixels. Our method of edgedetection and calculation
of
pixel blending ratio is sig-nificantly simpler and more effective than that of theprevious post-filtering approaches. It is also well-tunedfor efficient hardware implementation for real time com-puter graphics.
2
Pixel Connectivity
We define the
color intensity difference
of two pixels
Pa
and
Pb
as follows:
d(Pa,Pb)
=
lP,"
-
IP,"
-
PSI
-k
lp,"
-
PFl
(1)
where
P,",
P,", P,"
are the
RGB
values of pixel
P,,
re-spectively. We say that the pixels
Pa
and
Pb
are
con-nected
if
d(P,,Pb)
is below
a
predefined threshold
T,
otherwise we say they are
disconnected.
Also,
a
con-nected region
is
a
group of orthogonally adjacent pixelswhere the color intensity difference between any two ad-jacent pixels is below the threshold
T.
A
jaggy
is thusdefined as the boundary
of
such connected region whichhas staircase pattern.From
a
2D
image, horizontal and vertical pixel con-nectivities are first extracted and stored in two arrays ofBoolean value:
(2)
h(i,j)
=
d(p,,J,P*,J-l)
T,
cv(i,j)
=
d(P,,J,p,-l,J)
<
T
where
P,,J
is the pixel color value
at
(i,j),
ch(i,j)
s thehorizontal pixel connectivity, and
cv(i,
)
s the verticalpixel connectivity.
3
Jaggy Extraction Algorithm
Jaggies are extracted by two phases: jaggies whose slopeis between
-45"
and
45"
angle are extracted by
horizon-tally
scanning two adjacent rows of pixels, and jaggieswhose slope
is
between
45"
and
135'
angle are extractedby
vertically
scanning two adjacent columns.
0-7803-5471-0/99/$10.0001999
EEE
IV-532
 
j-1
j
j-1
j
j-1
j
i
i ii-1 i-1 i-1if cv(i, j-1
j=
andch
I
J)
1 and ch(i-1,
j)
=
1and ch[;-;
,E
=
0
if cv(i, j-1)
=
1and ch(i,j)
E
0
openingti)
:
UP openingti)
:
DOWN openingu)
:=
NULLotherwise
j-1
j
j-1
j
j-1 j
i
i ii-1 i-1 i-1if cvfi.
i)
=
1
if
cv(i.
i)
=
1
otherwisend
c@-1,
j)
=
1and ch(i,
j)
=
0
and
cwi,
))
=
1and ch(i-1, j)
=
0
closingti)
:=
UP closingti)
:=
DOWN closing(j)
:=
NULL
Figure
1:
Shapes
of
connected region
on
the scanningpoints.
jaggy-head jaggy-tailif (jaggy-head
=
UP and jaggy-tail
f
DOWN
or
jaggy-head
#
DOWN and jaggy-tail
=
UP)jaggy-shape
:=
"INC".
else if (jaggy-head
=
DOWN and jaggy-tail
#
UP
or
jaggy-head
#
UP and jaggy-tail
=
DOWN)jaggy-shape
:=
"DEC".else
if
(jaggy-head
=
UP and jaggy-tail
=
DOWN)jaggy-shape
:=
"MAX".
else jaggy-shape
:=
"MIN"
Figure
2:
Jaggy shape evaluation.When scanning the two pixel rows
i
and
i
-
1
hori-zontally from left to right, we first detect the startingpoint of the jaggy, and then detect its termination. De-tection of the starting point and termination point of
a
jaggy
as
well as its shape are determined by the shapes ofthe connected region at each scanning point
j
as shownin Fig.1 (denoted as
opening(j)
and
closing(j)).
Here,the conditions for detecting the start
of
jaggy and thetermination of jaggy are:
1.
If
jaggy is not pending, and
opening(j)
#
NULL,
thenIn this case, assign
jaggy-head
:=
aggy starts
at
j.
opening(j).
2.
If jaggy
is
pending, and
cv(i,j)
=
1
or
(jaggy-head
=
UP
and
ch(i,j)
=
0)
or
(jaggy-head
=
DOWN
and
ch(i
-
1,j)
=
0),
then jaggy has terminated at
j.
In this
Figure 3: Simple line fitting.
El
(a)
Simple line fitting
(b)
Our smooth
line fitting
Figure 4:smooth line fitting.Comparison of simple line fitting and our
case, assign
jaggy-tail
:=
closing(j).
And also:
0
If
cv(i,j)
=
1,
there are
no
pending jaggy.
0
Else
if
ch(i,j)
=
0
and
ch(i
-
1,j)
=
0,
then
a
new jaggy has started
at
j.
In this case, assign
jaggy-head
:=
opening(j).
0
Else
another jaggy is pending.
The shape of the jaggy is then determined by
jaggy-head
and
jaggy-tail
as shown in Fig.2.
4
Smooth Line Fitting Algorithm
After the jaggy has been extracted and its length andshape evaluated, we need to calculate the jaggy slopeand the pixel blending ratio
at
each pixel
on
the jaggy.Bloomenthal[3] and Overveld[4] use
a
simple line fit-ting method which is illustrated in Fig.3. In the caseof Fig.3(a), the jaggy slope is determined solely by thejaggy length
(1
/
jaggy-length),
and the line is posi-tioned
so
that it crosses the jaggy boundaries at halfway point which makes the fitted lines on the adjacentjaggies to be continuous
at
the jaggy boundaries. In thecase of Fig.3(b), it is considered as horizontal edge andthus
a
horizontal line is fitted. The problem of this sim-ple line-fitting algorithm is that the slope of the fittedline can only be the inverse of integers (1,1/2,1/3,.
.
),
therefore the accuracy
of
the fitted line is quite limited.Especially when the actual edge slope is close
to
45",
jaggy cannot be effectively removed. Also, fitting
a
hor-izontal line in the case of Fig.3(b) can cause unnaturalappearance since the original edge may actually be con-tinuing from the left jaggy.In order to deal with these problems,
we
use the lengthinformation of three adjacent jaggies to determine the
IV-533
 
line slope
of
the middle jaggy. Let
IO
and
11
be thestarting point and the termination point of
a
jaggy atrows
i
and
i
-
1,
and let
L
be the jaggy length
(L
:=
21
-
20
+
1).
If
the jaggy shape is
“INC”,
hen
1.
If
there is an adjacent jaggy terminating at
20
-
1
whoseshape is
“INC”
with a length
of
Lo,
then
1
(Lo
>
L)
0
(Lo
=
L)
else
do
:=
0.
2.
If
there is
a
adjacent jaggy starting at
+
1
whoseshape
is
“INC”
with
a length
of
L1,
then
1
(L1 >L)
0
(L1 =L)
else
dl
:=
0.
3.
Set the line equation as
Similar calculation is done for the case when the jaggyshape is
“DEC”.
mportant point here is that we modifythe length of the jaggy by f2/3,f1/3
or
0,
dependingon the length
of
the adjacent jaggies. In this way, wecan increase the accuracy of the fitted line (line slopecan now have the values 1,3/4,3/5,3/6,3/7,.
.
),
andfurther reduce the aliasing effect especially on edges near
.
45O
angle.Next, if the shape is
“MAX”,
1.
If
there is a jaggy terminating at
20
-
1
with length
LO,
then let
fo(z)
:=
(z
-
0
+
1/2)/Lo
+
i
-
1.
Otherwise
LO
=
0 and
fo(z)
:=
i
-
1.
2.
If
there is a jaggy terminating at
21
+
1
with length
L1,
then let
fl(z)
=
-(z
-
1
-
1/2)/L1
+i
-
1.
Otherwise
L1
:=
0
and
fl(z)
:=
-
1.
3.
If
Lo
>
1
or
L1
>
1,
then set the line equation aselse
y
=
i
-
/2.
Similar calculation is done for case when the jaggy shapeis
“MIN”.
Here we simply extend the fitted lines on theleft and right
of
the jaggy to the middle jaggy region.Fig.4 shows the comparison
of
simple line fitting andour modified smooth line fitting.
5
Pixel Blending Ratio Calcula-
t
ion
After the fitted lines are calculated, we need to com-pute the blending ratio of the pixels on the jaggy. Whenthe fitted line equation
is
given
as
in eq.(3), the blend-ing ratio between the two vertically adjacent pixels onrows
i
-
1
and
a
becomes
b(j)
:=
(j
-
0/3
+
1/2)/(L
+
do/3
+
d1/3) where
j
=
0,1,
a..
,
L
-
1
and
0
<
b(j)
<
1.
b(j)
can be obtained by calculating the gradient
db
:=
1/(L
+
d0/3
+
d1/3) and
b(O),
and then simply accu-mulate
db:
i.e.
b(j
+
1)
:=
b(j)
+
db.
Here, we haveobtained that
6
bits
for
representing the blending factoris enough without any noticeable difference comparedwith floating-point representation. Let
n
be the num-ber of bits to represent the blending factor. Followingdescribes the blending ratio calculation which adopts
in-cremental linear interpolation
algorithm
[5].
Blending Calculation(L, do,
dl):
W
:=
3L
+
do
+
dl.
N
:=
3.2”.
q
:=
LN/Wj.
r
:=
N
mod
W.
a
:=
0.
For
j
=
0
to
L
-
1
c
:=
q/2
+
do
.
12”/Wj.
b(j)
:=
c.c:=c+q.
a
:=
a
+r.
If a
1
W,
then
a
:=a
-
W.
c
:=
c+
1.
Here,
q
and
T
are the quotient and the remainder of
N
divided by
W.
The term
c
:=
q/2
+
do
.
L2”/W] calcu-lates the initial value of the blending factor
b(0).
Thenat each iteration,
q
and
r
are accumulated in
c
and
a,
respectively, and when
a
becomes larger than
W,
c
isincremented by
1.
These operations avoid the exact di-vision of
N/W
by evaluating the accumulated remainder
a.
Values
LN/WJ,
N
mod
W,
nd L2n/WJ can be pre-computed and stored in
a
lookup table. When
n
=
6,
only
3
.
26
+
2
=
194 entries are needed in the lookuptable.
6
Results
Here, we show the results of our anti-aliasing methodon
a
3D graphics image. The original image is shown inFig.5, where the image size is 400
x
400. In Fig.6, the re-sult
of
anti-aliasing using our method is shown, where allthe visible jaggies have effectively been smoothed with-out causing any blurring
of
the details. Here, the blend-ing factor is represented using
6
bits.
IV-534

Share & Embed

More from this user

Recent Readcasters

Add a Comment

Characters: ...