SUPERCO
VER PLANE RASTERIZATION
A Rasterization Algorithm for Generating Supercover Plane Inside a Cube
T. Petkovi
´
c and S. Lon
ˇ
cari
´
c
University of Zagreb, Faculty of Electrical Engineering and Computing, Unska 3, Zagreb, Croatia
Keywords:
Computer graphics, supercover plane rasterization.
Abstract:
An analysis of a rasterization algorithm for generating supercover planes in 3D voxel space is presented. The
derived algorithm is an extension to the classical 2D line rasterization algorithm. Additional voxels needed
to form the supercover 3D plane are identified by rasterizing two additional 2D lines per volume slice. A
discussion on how to modify the algorithm to rasterize finite supercover 3D plane segments with arbitrary
parameters by using integer arithmetic only is given.
1 INTRODUCTION
One of the problems in various applications of com-
puter graphics along with line drawing is rasteriza-
tion of planar surfaces. Our ability to obtain huge
volumetric data is ever increasing, especially in bio-
medical fields where 256
3
is currently the most com-
mon volume size. When analyzing such volumetric
data-sets one is not always satisfied with the simple
line and plane drawing and rasterization algorithms
as some interesting and sometimes not desirable ef-
fects can be introduced, such as existence of tunnels
in surfaces—for example 26-connected line can pass
through the 18-connected plane (Cohen-Or and Kauf-
man, 1997).
Most popular algorithm for line drawing was pre-
sented by Bresenham (Bresenham, 1965), and first
generic study on plane rasterization was done by Kim
(Kim, 1984). A fast plane weaving algorithm for ras-
terizing 18-connected digital planes was described by
Lincke at al. (Lincke and W
¨
uthrich, 1999). In this
article a simple 3D supercover plane generation algo-
rithm is presented. The described algorithm is an ex-
tension of the weaving algorithm presented by Lincke
et al.
The article is organized as follows: in section 2
we present the notation and definitions. In section 3
a review of exact weaving plane algorithm is given.
Section 4 presents an idea for weaving the 3D super-
cover plane and explains details about the rasteriza-
tion algorithm. We conclude the article in section 5.
2 PRELIMINARIES
Let R be the set of real numbers and let Z be the set
of integers. When digitizing three dimensional space
a grid usually used is the cubic grid. As we are inter-
ested in finite volumes only a subset of Z
3
is needed.
Our area of interest is thus a subset of 3D Euclidean
space R
3
consisting of all points whose coordinates
are integers and are within some chosen intervals.
Square brackets denote both the rounding operator
and a set of all residues module q, but only when the
index is written, making [x] the rounding operator and
[p]
q
the set of all residues of p modulo q.
A voxel in R
3
corresponding to a discrete point
(x, y,z) Z
3
is defined by the continuous unit cube
with the center at (x, y, z). Let us denote the cube as-
sociated with one voxel as V(x,y, z) = [x
1
2
, x +
1
2
]×
[y
1
2
, y +
1
2
] × [z
1
2
, z +
1
2
].
The voxel is sometimes
called spel (spatial element). A face of a cube associ-
ated with a voxel is just a face, but if two voxels are
in relation then corresponding shared face is called a
surfel (surface element). Let X be any set and ρ be a
binary relation on X. If (p, q) ρ then p is ρ-adjacent
of q. If ρ is a symmetric relation then for any p, q X
327
Petkovi
´
c T. and Lon
ˇ
cari
´
c S. (2007).
SUPERCOVER PLANE RASTERIZATION - A Rasterization Algorithm for Generating Supercover Plane Inside a Cube.
In Proceedings of the Second International Conference on Computer Graphics Theory and Applications - GM/R, pages 327-332
DOI: 10.5220/0002079303270332
Copyright
c
SciTePress
(p, q) ρ if and only if (q, p) ρ. We say that p and
q are ρ-adjacent (Herman, 1998). For X = Z
3
we de-
fine three symmetric binary relations on Z
3
that cor-
respond to 26, 18 and 6 voxel connectivity. For any
two points p = (p
1
, p
2
, p
3
) and q = (q
1
, q
2
, q
3
) of Z
3
we say that they are 18 connected or (p, q) δ
3
if and
only if they share a face or an edge.
The simplest plane rasterization in 3D is 18-
connected, so adjacent voxels in a digital plane will
share a face or an edge. Such plane is not tunnel-
free and 26-connected line can pass through the plane.
For some applications, especially in biomedical im-
age analysis, this is not acceptable one must find a
tunnel-free plane. A supercover plane is one likely
candidate as it has some additional desirable proper-
ties (Andr
`
es, 2003) beside being a tunnel-free struc-
ture. We will adopt the definitions by Andr
`
es (Andr
`
es,
2003):
Definition 2.1 (Supercover) A supercover S(X) of a
continuous object X is the set of all the discrete points
p Z
n
and associated voxels such that V(p)X 6=
/
0.
One of the drawbacks of the supercover objects is ex-
istence of bubbles.
Definition 2.2 (Bubble) A k-bubble is the supercover
of an Euclidean point that has exactly k half-integer
coordinates.
3 AN EXACT WEAVING OF
DIGITAL PLANE
An attractive method to produce digital planes is
by using weaving techniques (Lincke and W
¨
uthrich,
1999). Basic idea is to decompose surface rasteriza-
tion into two orthogonal curve rasterizations. For the
planes both curves are lines and by copying one along
the other the plane rasterization is obtained. The line
being copied is usually called master and the line used
for determining the positions of the master is called
base. As all lines in the plane along the base are
copies of the master and thus have the same chain
code we only need to compute the rasterizations of
the master line and of the base line. Copying the mas-
ter line along the base completes the plane weaving.
We usually denote a line with the letter L. Being
interested in lines with the same slope and different
intercepts only we just need to know the value of the
intercept.
Definition 3.1 (Straight line) For any k Z and a
pair p and q of relatively prime numbers, q 6= 0, the
straight line L
k
is a set of points L
k
= {(x, y) R
2
:
y =
p
q
x +
k
q
}.
2
4
6
8
1
0
2
4
6
8
1
0
1
2
3
4
5
6
2
4
6
8
1
0
2
4
6
8
1
0
1
2
3
4
5
6
Figure 1: A continuous and digital representation of the
plane defined by x + 2y 5z = 0. For the digital represen-
tation voxels belonging to the master. are shown as wire-
frame and base is shown using darker shading.
This is sufficient for almost all applications as dis-
cussed in section 4.2.
When copying the master line one must notice that
simple copying of the master along the base will not
produce nearest neighbor rasterization as defined in
(W
¨
uthrich, 1998). To obtain a proper rasterization
one must also consider shift in the line chain code
that is introduced as the intercept changes. Lincke et
al. (Lincke and W
¨
uthrich, 1999) have presented an ex-
act weaving rasterization algorithm for digital planes.
Main result is the theorem stating how to compute a
shift of any line at given position:
Theorem 3.1 (Line shift) Let L
e
be a straight line
given by y(x) =
p
q
x + e where p and q are relatively
prime numbers, p, q Z, p q, q 6= 0 and e is an
arbitrary real intercept. The shift s of L
e
at position
i Z is given by [s]
q
= [rp
]
q
with r = [pi + qe]
q
if q
is odd and r = [pi + qe +
1
2
]
q
if q is even.
The weaving algorithm now copies the master line
along the base, but the chain code is shifted by s. An
example rasterization of the plane x + 2y 5z = 0 is
shown in figure 1.
The plane weaving algorithm produces an exact
rasterization of the plane Ax + By + Cz + D = 0 with
rational coefficients A, B, C and D. Produced rasteri-
zation is 18-connected set that does not contain all the
voxels a plane intersects. In figure 2 an 18-connected
plane x + 2y 5z = 0 is superimposed over continu-
ous plane. One can immediately notice that contin-
uous plane is not contained within the 18-connected
GRAPP 2007 - International Conference on Computer Graphics Theory and Applications
328
Figure 2: A continuous plane x + 2y 5z = 0 is not con-
tained within 18-connected digital representation.
representation.
4 EXTENSION TO SUPERCOVER
PLANES
Consider a continuous plane P given by Ax + By +
Cz + D = 0 where A, B,C, D Z. Let also a be an
absolute value of A etc., so a = |A|, b = |B|, c = |C|
and d = |D|. Without loss of generality we can as-
sume 0 < a, b c. The implicit formula for such
plane is z =
1
C
(Ax +By +D) with the corresponding
18-connected rasterization Dig(P) =
©
(x, y,z) : x, y
Z, z =
£
1
C
(Ax + By +C)
¤ª
. The supercover rasteri-
zation S(P) of the plane P is slightly different, and is
defined by S(P) =
©
(x, y,z) Z
3
:
¥
a+b+c
2
+ D
¦
<
Ax + By +Cz
¥
a+b+c
2
D
¦
+1
ª
. When weaving an
arbitrary plane we simply copy the master line. To
each copy we can assign one slice of the space Z
3
.
Definition 4.1 (Slice) A slice S
i
(k), k Z, in discrete
space Z
n
is a subset of spels with i-th coordinate fixed,
S
i
(k) = {x Z
n
: x
i
= k}.
We will call two slices S
i
(k) and S
i
(l) adjacent iff |k
l| = 1.
Weaving algorithms compute 2D rasterization of
a line in one slice which is then replicated for all
other slices we are interested in. When we want to
obtain a supercover rasterization of a plane segment
we must trace two additional lines per slice along
with the master line as shown in figure 3. The mas-
ter line (dot-dash line in the figure) corresponds to
the line L
m
: z =
A
C
x
1
C
(By
0
+ D), so the inter-
cept is
1
C
(By
0
+ D) and m =
A
C
. The lower line
L
l
and the upper line L
u
are passing through planes
with half-integer coordinates in y. Again, without loss
of generality we can assume the slope of the plane
along y dimension is such that z increases as we move
from y
0
1
2
to y
0
+
1
2
(so B > 0). Upper and lower
lines are now L
u
: z =
A
C
x
1
C
(By
0
+
B
2
+ D) and
L
l
: z =
A
C
x
1
C
(By
0
B
2
+ D).
Lemma 4.1 (Continuity) For plane P and two adja-
cent slices S
i
(k) and S
i
(l) either L
l
from S
i
(k) and L
u
from S
i
(l) or L
u
from S
i
(l) and L
l
from S
i
(k) are the
same.
The result is obvious and follows immediately from
|n m| = 1. Together with the following theorem by
Lincke et al. (Lincke and W
¨
uthrich, 1999) it provides
the basis for weaving supercover planes.
Theorem 4.2 (Line Equivalence) Let L
k
be the 2D
line y =
p
q
x +
k
q
where p and q are relatively prime.
For all k Z the set of straight lines L
k
having the
same rasterization (up to shift) is an equivalence class
and it contains all lines defined by y =
p
q
x + e, e R
with
k
q
1
2q
< e
k
q
+
1
2q
if q is odd and
k1
q
< e
k
q
if q is even.
In our example the intercept e for upper and lower line
is
e
=
1
C
(
By
0
±
B
2
+
kB
)
. We must show that for up-
per and lower lines in two adjacent slices we obtain
the same line cover when shift is introduced—when
we copy the master slice lower (or upper) line raster-
ization in one slice must be equal to the rasterization
of the upper (or lower) line in the adjacent slice.
Lemma 4.3 (Equal shifts) When copying the three
lines in master slice S
i
(0) to slice S
i
( j) shifts s
m
, s
u
and s
l
are at constant shift distance.
We must compute shifts for three lines L
m
, L
l
and
L
u
. All three lines have the same slope, but the in-
tercepts are different. By theorem 3.1 for odd C
we have [s
m
]
q
= [[p j + qm]p
]
q
= [[A j + B j +D]A
]
c
,
[s
u
]
q
= [[p j + qu]p
]
q
= [[A j + B j +
B
2
+ D]A
]
c
and
[s
l
]
q
= [[p j + ql]p
]
q
= [[A j + B j
B
2
+ D]A
]
c
. As
A j + B j + D is a whole number we have [s
u
]
c
=
[(A j + B j + D)A
+ [
B
2
]A
]
c
= [s
m
]
c
+ [[
B
2
]A
]
c
and
[s
l
]
c
= [s
m
]
c
[[
B
2
]A
]
c
. The distance between the
shifts is the same, so we do not need to copy three
lines separately, but we can copy the whole slice.
Without loss of generality let us compare the
lower line L
l
and upper line L
u
in one slice when 0 <
a b c. Note that both lines have the same slope.
Corresponding intercepts are e
u
=
1
C
(By
0
+
B
2
+ D)
and e
l
=
1
C
(By
0
B
2
+D). As q = C for odd C and
upper line L
u
we have
k
u
C
+
1
2C
< e
u
k
u
C
1
2C
.
Doing the same for L
l
we obtain two inequalities
k
u
1 <
1
2
(2By
0
B + 2D 1) k
u
and k
l
1 <
SUPERCOVER PLANE RASTERIZATION - A Rasterization Algorithm for Generating Supercover Plane Inside a Cube
329
0
2
4
6
8
10
0
1
2
1
0
1
2
3
4
0
1
2
0
1
2
−1
0.5
0
0.5
1
1.5
2
2.5
3
Figure 3: A middle line with upper and lower lines we need for obtaining the supercover plane rasterization. On the right a
single voxel belonging to the master line is shown. For each such voxel we must determine where the intersections between
upper (or lower) line and neighboring voxel’s borders are.
1
2
(2By
0
B + 2D 1) k
l
. By examining obtained
inequalities for odd and even B, and then for even C
we can compute the difference between the intercepts.
We obtain k
u
k
l
= B or u l = B.
Lemma 4.4 (Switching) When copying the upper,
master and lower lines for two adjacent slices S
i
(k)
and S
i
(l) covered voxels faces selected by upper line
from one slice and lower line from another will be the
same.
Let us first compute the shift distance between two
master lines in two adjacent slices S
i
(k) and S
i
(l),
l = k + 1. We have [s
m,k
]
c
= [[Ai + Bk + D]A
]
c
and
[s
m,l
]
c
= [[Ai + B(k + 1) + D]A
]
c
= [s
m,k
]
c
+ [BA
]
c
,
so two slices are shifted by [BA
]
c
. Note that as the
shift between any two adjacent slices is the same we
can simply shift-and-copy the chain codes from the
previous slice. Now as [s
l,k+1
]
c
and [s
u,k
]
c
are shifted
by ±[[
B
2
]A
]
c
shifts for upper and lower line are also
the same.
By combining those results we can state that in-
tersection of voxel faces selected by the master and
lower (or upper) line from slice S
i
(k) and voxel faces
selected by the master and upper (or lower) line from
slice S
i
(l) will form the supercover of the line shared
by two slices. So when weaving supercover planes we
find two 2D supercover rasterizations of the upper and
lower lines (they must contain the master line), for ex-
ample by using modified Bresenham algorithm pre-
sented in (Dedu, 2002). However, we can trace orig-
inal line and only check whether the upper or lower
lines have a non-empty intersection with the upper or
lower adjacent voxel as shown in figure 3.
4.1 Computing the Cover for One Slice
How can we compute the cover for one slice only?
Our plane P is given by Ax + By + Cz + D = 0 with
0 < a b c. If we start the line at coordinates
(x
0
, y
0
, z) we can compute the shifts [s
m
]
c
, [s
l
]
c
and
[s
k
]
c
and then we can copy the chain codes as done in
(Lincke and W
¨
uthrich, 1999) for naive planes. Now
we have several possibilities for plane weaving: a)
we compute the shift for each slice as done by Lincke
et al. (Lincke and W
¨
uthrich, 1999), or b) we com-
pute the shift difference between two adjacent slices
and simply correct the shift from previous slice (p
required for the shift computation can be computed
when rasterizing the master slice). Alternatively we
can compute the starting values for error variables and
rasterize each slice separately.
Let us compute the starting error for a single slice.
The real value of z coordinate is
A
C
x
0
1
C
(By
0
+ D),
and [z] is the closest integer value. Now the error vari-
able is difference z [z] scaled to 2C, so
e
z
= 2C(z [z]) = 2(Ax
0
By
0
C[z] + D).
When computing the cover for one slice we also need
the to know the error variables for the upper and lower
lines. When 0 < a b c the error from the slice
defined by [z] for the lower line is e
l
= e
z
a b, and
for the upper line is e
u
= e
z
+a +b. If either of e
l
or e
u
fall outside of the voxel the lower and upper lines will
start at [z] + 1 or [z] 1 respectively. Now we trace
those three lines simultaneously to obtain the cover
for one slice.
The upper line and the lower line must be super-
cover lines. In the previous section we have shown
that the chain codes for upper line and lower line are
shifted ±[[
B
2
]A
]
c
when compared to the master, how-
ever we must note that the computed shift is for the
GRAPP 2007 - International Conference on Computer Graphics Theory and Applications
330
Figure 4: A 18-connected digital representation of the plane
defined by x + 2y 5z = 0 and it’s supercover.
simple chain code. As we want to compute the super-
cover of the both upper and lower lines unfortunately
the rounding operator must have different definitions
for those lines. The rounding operator [x] is defined
by k
1
2
< x k +
1
2
. The problem occurs when ei-
ther of upper and lower lines passes exactly through
the point with half-integer coordinates. For the up-
per line as is shown in figure 3 we must select upper
voxel when the line passes through back upper right
voxel vertex (shown as a circle), and for the lower line
we must select the lower voxel when the line passes
through front lower left vertex (also shown as a cir-
cle). So the rounding operator is different for lower
and upper lines.
By using similar reasoning as done in the previous
section we can show that the shift for the supercover
case will differ at most by one when compared to the
shift ±[[
B
2
]A
]
c
. The additional shift by one is con-
sistent for all the slices and will not affect the cover
shared between two slices. By copying and shifting
the slice we can obtain the plane.
One rendering of a plane is shown x + 2y 5z = 0
in figure 4. Note that one should expect the regular
chain codes for upper and lower lines to be shifted by
±[[
B
2
]A
]
c
= ±1, but as the lines are supercover the
shift is two.
4.2 Restriction to a Finite Volume
For majority of applications we are interested in com-
puting a plane within a finite volume—usually a cube
or a parallelepiped, so the plane-generating algorithm
must be able to draw planes with arbitrary parameters
only within some chosen sub-volume.
Chain code of the digital 2D line y =
p
q
n + e with
p, q N and 0 < p q is periodic. If p and q are
relatively prime the period is q (Pham, 1987). If we
restrict the continuous plane P : Ax+By +Cz +D = 0
with arbitrary parameters (so A, B,C, D R) to a cube
we want to find another plane having the same raster-
ization, but with the coefficients being whole num-
bers. Without the loss of generality we can only
consider the planes where 0 < a, b c such that in-
tersection with the parallelepiped is not an empty
set. As the C is the largest coefficient by absolute
value when rasterizing a plane we compute only z
coordinates, [z] = [
1
C
(Ai + B j + D)], so a digitized
plane would be Dig(P) =
©
(i, j, k) : i, j [i
1
, i
2
] ×
[ j
1
, j
2
], k =
£
1
C
(Ai + B j + C)
¤ª
. For the digitized
coordinates we require the following inequalities to
have same solutions in k:
k
1
2
1
ˆ
C
(
ˆ
Ai +
ˆ
B j +
ˆ
D) k +
1
2
(1)
k
1
2
1
C
(Ai + B j + D) k +
1
2
(2)
Here the
ˆ
A,
ˆ
B,
ˆ
C and
ˆ
D are whole numbers rep-
resenting a plane that has same rasterization as the
plane P. For the midpoint line drawing algorithm
usually we double all the values, so we can expect
similar result for the supercover plane case. Let us
assume that
ˆ
A = [αA],
ˆ
B = [αB] etc., where α is a
positive real constant. We rewrite the (1) and (2)
so
£
1
[αC]
([αA]i + [αB] j + [αD])
¤
=
£
1
C
(Ai + B j +
D)
¤
and consequently
¯
¯
1
[αC]
([αA]i+[αB] j +[αD])+
1
C
(Ai + B j + D)
¯
¯
<
1
2
. Now we have
[αA] < 2
³
[αA]i + [αB] j
Ai + B j + D
C
[αC] + [αD]
´
< [αC],
(3)
and 0 < a, b c. As
ˆ
C = [αC] is an integer we can
select α =
n
C
, n N, so
ˆ
C = n. Now (3) transforms to
2
¯
¯
¯
³h
n
n
A
C
oi
n
n
A
C
i +
³h
n
n
B
C
oi
n
n
B
C
j +
³h
n
n
D
C
oi
n
n
D
C
¯
¯
¯
< |n|.
(4)
As ([n{
A
C
}] n{
A
C
}) and other similar constructs
are always between
1
2
and
1
2
we find the worst
SUPERCOVER PLANE RASTERIZATION - A Rasterization Algorithm for Generating Supercover Plane Inside a Cube
331
Figure 5: A 18-connected digital representation of the plane
defined by 5x + 5y 5z = 0 and it’s supercover.
case |
ˆ
C| = |n| > max|i| + max| j| + 1. In fact,
when rasterizing arbitrary plane within finite volume
we only need to check the size of the finite vol-
ume. Consequently, we can scale the coefficients so
the largest one has the absolute value greater then
max
¡
|i
1
|, |i
2
|
¢
+ max
¡
| j
1
|, | j
2
|
¢
+ 1.
5 CONCLUSION
A supercover plane algorithm that uses only integer
arithmetic was presented. Two variants are possible,
one that simply traces a line for each slice and a weav-
ing algorithm. Additionally, it was shown that if we
want to draw a finite segment of a plane within a fi-
nite volume we only need to scale and round the plane
coefficients.
If the square plane segment of side lengths n and
m, n < m has to be generated the complexity of first
approach is O(mn). The weaving approach needs to
generate one line segment of the length q and then it
is copied n times, so we can expect the complexity of
O(nq). Due to the large variety of available hardware
performance analysis and code profiling was not done
as it would probably be application and hardware spe-
cific, however we are currently working on this prob-
lem.
REFERENCES
Andr
`
es, E. (2003). Discrete linear objects in dimension n:
the standard model. Graph. Models, 65(1-3):92–111.
Bresenham, J. E. (1965). Algorithm for computer control
of a digital plotter. IBM System Journal, 4(1):25–30.
Cohen-Or, D. and Kaufman, A. (1997). 3D line voxeliza-
tion and connectivity control. Computer Graphics and
Applications, 17(6):80–87.
Dedu, E. (2002). Design of a Simulation Model of Multi-
Agent Systems, and its Parallel Algorithmic and Im-
plementation on Shared-Memory MIMD Computers:
ParSSAP Model. PhD thesis, PRiSM, UVSQ, Ver-
sailles, France.
Herman, G. T. (1998). Geometry of Digital Spaces. Ap-
plied and Numerical Harmonic Analysis. Birkh
¯
auser,
Boston.
Kim, C. E. (1984). Three-dimensional digital planes. IEEE
Transactions on Pattern Analysis and Machine Intel-
ligence, 6(5):639–644.
Lincke, C. and W
¨
uthrich, C. A. (1999). An exact weaving
rasterization algorithm. In Skala, V., editor, WSCG’99
Conference Proceedings.
Pham, S. (1987). Equations of digital straight lines. In CG
International ’87 on Computer graphics 1987, pages
221–248, New York, NY, USA. Springer-Verlag New
York, Inc.
W
¨
uthrich, C. A. (1998). A model for curve rasterization in
n-dimensional space. Computers & Graphics, 22(2–
3):153–160.
GRAPP 2007 - International Conference on Computer Graphics Theory and Applications
332