Content uploaded by Paul L. Rosin
Author content
All content in this area was uploaded by Paul L. Rosin on Oct 22, 2014
Content may be subject to copyright.
A Rectilinearity Measurement for Polygons
Joviˇsa ˇ
Zuni´cand Paul L. Rosin
Computer Science, Cardiﬀ University,
Queen’s Buildings, Newport Road, PO Box 916,
Cardiﬀ CF24 3XF, Wales, U.K.
{J.Zunic, Paul.Rosin}@cs.cf.ac.uk
Abstract. In this paper we deﬁne a function R(P) which is deﬁned
for any polygon Pand which maps a given polygon Pinto a number
from the interval (0,1].The number R(P) can be used as an estimate
of the rectilinearity of P. The mapping R(P) has the following desirable
properties:
– any polygon Phas the estimated rectilinearity R(P) which is a num
ber from (0,1];
–R(P)=1 if and only if Pis a rectilinear polygon, i.e., all interior
angles of Pbelong to the set {π/2,3π/2};
– inf
P∈ΠR(P)=0,where Πdenotes the set of all polygons;
– a polygon’s rectilinearity measure is invariant under similarity trans
formations.
A simple procedure for computing R(P) for a given polygon Pis de
scribed as well.
Keywords: Shape, polygons, rectilinearity, measurement.
1 Introduction
Shape plays an important part in the processing of visual information, and is
actively being investigated in a wide spectrum of areas, from art [13] through to
science [3]. Within computer vision there have been many applications of shape
to aid in the analysis of images, and standard shape descriptors include com
pactness, eccentricity [12], circularity [4], ellipticity [9], and rectangularity [11].
This paper describes a shape measure that has received little attention: rec
tilinearity. While there exists a variety of approaches to computing the related
measure of rectangularity [11], rectilinearity covers a wider space of shapes since
the number of sides of the model shape is variable. It is only required that the
angles of a rectilinear polygon belong to the set {π/2,3π/2}. This means that
it is not convenient to ﬁt the model1to the data and measure the discrepan
cies between the two, which is the approach that is often applied to compute
compactness and rectangularity.
J. ˇ
Zuni´c is also with the Mathematical Institute of Serbian Academy of Sciences,
Belgrade.
1Fitting a rectilinear shape is possible, as demonstrated by Brunn et al. [1], but is
complex, and potentially unreliable and inaccurate. Our proposed approach avoids
ﬁtting, and is therefore simpler and faster.
A. Heyden et al. (Eds.): ECCV 2002, LNCS 2351, pp. 746–758, 2002.
c
SpringerVerlag Berlin Heidelberg 2002
A Rectilinearity Measurement for Polygons 747
Our motivation in developing a rectilinearity shape measure is to provide
a useful tool for the analysis of buildings in aerial photographs. Over the last
1020 years there has been considerable research in this area with the goal of
providing automatic photo interpretation which would be particularly useful for
cartographers [2,5,6,8]. Such systems are typically based on perceptual grouping
of edges and incorporate additional information such as shadows, knowledge
based rules, as well as shape (typically rectangular). Since many buildings appear
rectilinear from an overhead view then such a shape measure could be used in
a hypothesis and test paradigm to ﬁlter out unlikely candidates which have
inappropriate shapes.
Let us conclude this introduction by noticing that a variety of rectilinearity
measures for polygons which are based only on a measure of the angles of the
considered polygon can be derived very easily. But such a deﬁned rectilinearity
measure would imply that the polygons with the same angles have the same
estimated rectilinearity which is not always acceptable (see Fig. 1).
PQ
Fig. 1. Two given 5gons have identical angles, but it is natural to expect that Pshould
have a higher estimated rectilinearity than Q.
2 Deﬁnitions and Basic Statements
A polygon Pis rectilinear if its interior angles belong to the set {π/2,3π/2}
(see Fig. 2 for an example). In this paper we deﬁne a rectilinearity measure for
arbitrary polygons. Precisely, we deﬁne a mapping R(P) which maps a given
polygon Pinto a number from the interval (0,1].
We will use the following denotations (see Fig. 3 and Fig. 4 for some illus
trations).
The set of all polygons will be denoted by Π. For a given ngon Phaving
vertices denoted by A0,A
1,...,A
n−1,A
n=A0, its edges will be denoted ei=
[Ai−1,A
i] for i=1,2,...,n. The Euclidean length of the straight line segment
e=[(x1,y
1),(x2,y
2)] is l2(e)=(x1−x2)2+(y1−y2)2, while the length of e
according to the l1metric is l1(e)=x1−x2+y1−y2.
748 J. ˇ
Zuni´c and P.L. Rosin
u
x
y
v
α
p
q
P
Fig. 2. For the given rectilinear 20gon P, its l1perimeter P1(P) has the minimum
value if the coordinate axes are chosen to be parallel with uand v. This minimum
value corresponds to P1(P, −α)ifxand yare taken to be the coordinate axes.
P2(P) will denote the Euclidean perimeter of P, while P1(P) will denote the
perimeter of Pin the sense of l1metrics. So,
P2(P)=
eiis an edge of P
l2(ei) and P1(P)=
eiis an edge of P
l1(ei).
Since isometric polygons do not necessarily have the same perimeter under the l1
metric, we shall use P1(P, α) for the l1perimeter of the polygon which is obtained
by the rotating Pby the angle αwith the origin as the centre of rotation. If the
same rotation is applied to the edge e, the l1perimeter of the obtained edge will
be denoted as l1(e, α).
If the oriented angle between the positively oriented xaxis and the vector
−−−−→
Ai−1Aiis denoted by φi(i=1,2,...n), then obviously l1(ei)=l2(ei)·(cos φi+
sin φi),while l1(ei,α)=l2(ei)·(cos(φi+α)+sin(φi+α)).Thus, by using
1≤cos β+sin β≤√2 (for any β), we have
P2(P)≤P
1(P, α)=
n
i=1
l2(ei)·(cos(φi+α)+sin(φi+α))≤√2·P2(P).(1)
We will exploit the following property of rectilinear polygons which is formulated
as a theorem.
Theorem 1. A given polygon Pis rectilinear if and only if there exists a choice
of the coordinate system such that the Euclidean perimeter of Pand the l1
perimeter of Pcoincide, i.e.,
A Rectilinearity Measurement for Polygons 749
=
A
32
e
3
5
e
1
A
1
2
3
4
5
A
0
A
5
A
x
y
2
e
1
eφ
φ
φ
φ
φ
A
44
e
Fig. 3. The used denotations are illustrated on an example of a given 5gon.
P2(P)=P1(P, α)for some α.
Proof. If the given polygon Pis rectilinear, then a rotation of P, such that
the edges of Pbecome parallel to the coordinate axes, preserves the equality
P2(P)=P1(P, α) where αis the rotation angle.
On the other hand, if P2(P)=P1(P, α) then (by using (1) and cos β+
sin β≥1) it must be cos(φi+α)+sin(φi+α)= 1 for any edge ei,1≤i≤n,
of the given ngon P. That means (for any i, 1≤i≤n) it is either cos(φi+α)=0
or sin(φi+α) = 0 – but it implies that all edges of Pare either parallel or
orthogonal to the same line. This completes the proof. [[]]
3 The Basic Idea and Necessary Mathematics
Theorem 1 gives a useful characterisation of rectilinear polygons and gives the
basic idea for the polygon rectilinearity measurement described in this paper.
In the ﬁrst stage, Theorem 1 together with P2(P)≤P
1(P) (see (1)) suggests
that the ratio P2(P)
P1(P)can be used as a rectilinearity measure for the polygon P.
Precisely, the ratio P2(P)
P1(P)has the following “good” properties:
a1) it is a strictly positive number;
a2) it is deﬁned for any polygon P;
a3) it can be calculated easily;
a4) for any non rectilinear polygon it is strictly less than 1 and for any rectilinear
polygon it is exactly 1 if the coordinate axes are suitably chosen.
750 J. ˇ
Zuni´c and P.L. Rosin
But, on the other side P2(P)
P1(P)has the following “bad” properties:
b1) it is not invariant under similarity (even isometric) transformations;
b2) the inﬁmum for the set of values of Q(P, α)= P2(P)
P1(P, α)is not zero; for an
example, it can be seen easily (from (1)) that there no exists a polygon P
such that P2(P)
P1(P)/∈0,√2
2.
In this section we develop necessary mathematical tools in order to deﬁne a
function R(P) which satisﬁes a1)–a5) but not b1) and b2).
The problem described by b1) can be avoided by considering max
α∈[0,2π]P2(P)
P1(P, α)
instead of P2(P)
P1(P),but it opens the question of how to compute this maximum.
Further, the inequalities from (1) give
√2
2≤P2(P)
P1(P)≤1,and consequently, √2
2≤max
α∈[0,2π]P2(P)
P1(P, α)≤1
for any polygon P. But, while the inequality P2(P)
P1(P)≤1 is sharp, and moreover,
the equality max
α∈[0,2π]P2(P)
P1(P, α)= 1 is satisﬁed if and only if Pis a rectilinear
polygon (due to Theorem 1), it can be seen easily that there exists no polygon
Psuch that max
α∈[0,2π]P2(P)
P1(P, α)=√2
2.Namely, if an ngon P satisﬁes the last
equality, then for some α0we have P2(P)
P1(P, α0)=√2
2which (by (1)) would imply
√2·l2(ei)=l1(ei,α
0) or, equivalently, φi+α0∈{π/4,3π/4,7π/2,9π/4}for any
edge eiwhere 1 ≤i≤n. Thus, Pmust be rectilinear, and due to Theorem 1,
the considered maximum must be equal to 1, which is a contradiction.
So, for our purpose it is necessary to determine the maximal possible µsuch
that max
α∈[0,2π]P2(P)
P1(P, α)belongs to the interval [µ, 1] for any polygon P. The next
two lemmas together show µ=π
4and moreover, there is no polygon Psuch
that max
α∈[0,2π]P2(P)
P1(P, α)=π
4.
Lemma 1. The inequality
max
α∈[0,2π]P2(P)
P1(P, α)>π
4
holds for any polygon P.
A Rectilinearity Measurement for Polygons 751
Proof. We prove the statement by a contradiction. Let us assume the contrary,
i.e., there exists an ngon Psuch that
P2(P)
P1(P, α)≤π
4
for any choice of α, or equivalently,
P1(P, α)
P2(P)≥4
πfor any α∈[0,2π].
Since P1(P, α)
P2(P)is a continuous non constant function (for more details see Section
5) depending on α(if Pis ﬁxed), and since it is assumed to be greater or equal
to 4
πit must be
2π
0
P1(P, α)
P2(P)·dα >
2π
0
4
π·dα =8.(2)
By using (2) we have:
8<
2π
0
P1(P, α)
P2(P)·dα
=1
P2(P)·
2π
0n
i=1
l1(ei,α)·dα
=1
P2(P)·
n
i=1
2π
0
l1(ei,α)·dα
=1
P2(P)·
n
i=1
2π
0
l2(ei)·(sin(φi+α)+cos(φi+α))·dα
=1
P2(P)·n
i=1
8·l2(ei)=1
P2(P)·P
2(P)·8=8.
The contradiction 8 <8 ﬁnishes the proof. [[]]
So, in accordance with the above discussion, Lemma 1 shows that the required
number µis not smaller than π
4. The next lemma shows that µis not bigger
than π
4. Thus, both lemmas together give µ=π
4.
752 J. ˇ
Zuni´c and P.L. Rosin
Lemma 2. The inﬁmum for the set of values max
α∈[0,2π]P2(P)
P1(P, α)for all possible
choices of polygon Pis π
4, i.e.,
inf
P∈Πmax
α∈[0,2π]P2(P)
P1(P, α)=π
4
Proof. To prove the statement it is enough to ﬁnd a sequence of polygons
P3,P
4,P
5,... such that
lim
n→∞ max
α∈[0,2π]P2(Pn)
P1(Pn,α)=π
4.
We will prove that the sequence of regular ngons Pninscribed into the unit circle
satisﬁes the previous equality. Namely, it can be seen easily that the sequence
of the Euclidean perimeters of Pntends to the perimeter of the unit circle, i.e.,
lim
n→∞ P2(Pn)=2·π(3)
but also
lim
n→∞ P1(Pn,α) = 8 (4)
holds independently on the choice of α. Precisely, if it is considered that (for any
α∈[0,2π]) the l1perimeter P1(Pn,α) equals the sum of the projections of all
edges of Pnonto xand yaxes, than it follows that this sum tends to 8 as n→∞
(see Fig. 4 for an illustration). Since the limits in (3) and (4) are independent
on αwe have
lim
n→∞ P2(Pn)
P1(Pn,α)= lim
n→∞ max
α∈[0,2π]P2(Pn)
P1(Pn,α)=π
4,
what ﬁnishes the proof. [[]]
4 A Rectilinearity Measure
Motivated by the proved properties of the function max
α∈[0,2π]P2(P)
P1(P, α)we give the
following deﬁnition for the new rectilinearity measurement of polygons.
Deﬁnition 1. For an arbitrary polygon Pwe deﬁne its rectilinearity R(P)as
R(P)= 4
4−π·max
α∈[0,2π]P2(P)
P1(P, α)−π
4.
The following theorem summarises the properties of the polygon rectilinearity
measure proposed here.
Theorem 2. For any polygon P, we have:
A Rectilinearity Measurement for Polygons 753
A
A
A
A
A
A
A
A
A
0
1
2
3
4
5
6
7
8
9
A
10
A
11
A=
5
e
5
sin).
2
cos
.
)e
5
(l
2


φ
φ
5

l
5
e(
φ
5

Fig. 4. A regular 11gon inscribed into the unit circle with the centre placed at the
origin.
i) R(P)is well deﬁned and R(P)∈(0,1];
ii) R(P)=1 if and only if Pis rectilinear;
iii) inf
P∈Π(R(P))=0;
iv) R(P)is invariant under similarity transformations.
Proof. For a ﬁxed P,P2(P)
P1(P, α)is a continuous function depending on α(for
more details see the next section). Consequently, it must reach its minimum on
the closed interval [0,2π], i.e., R(P) is well deﬁned. R(P)∈(0,1] follows from
(1), Deﬁnition 1, and Lemma 1.
The item ii) is a direct consequence of Theorem 1.
The item iii) is the statement of Lemma 2.
To prove iv) let us notice that R(P) is invariant under all isometric transforma
tions – which follows from the deﬁnition. Also, P2(P)
P1(P, α)and consequently R(P)
are invariant under any transformation of the form (x, y)→(λ·x, λ ·y) for any
choice of λ=0,P, and α. That completes the proof. [[]]
Some examples of polygons with their computed rectilinearity are given on
Fig. 5.
754 J. ˇ
Zuni´c and P.L. Rosin
5 Computation of R(P)
The question which remains open is how to compute R(P) eﬀectively if a polygon
Pis given. Since P2(P) can be easily calculated from the vertices of Pit remains
to describe the computation of the minimum value of P1(P, α) when αvaries
from0to2π. In this section we describe a procedure for such a computation.
Let us consider an edge ei(1 ≤i≤n) of a given ngon P. Trivially,
l1(ei,α)=
+l2(ei)·cos(φi+α)+l2(ei)·sin(φi+α)ifα∈[−φi,π
2−φi]
−l2(ei)·cos(φi+α)+l2(ei)·sin(φi+α)ifα∈[π
2−φi,π−φi]
−l2(ei)·cos(φi+α)−l2(ei)·sin(φi+α)ifα∈[π−φi,3π
2−φi]
+l2(ei)·cos(φi+α)−l2(ei)·sin(φi+α)ifα∈[3π
2−φi,2π−φi].
Consequently, there is an integer k≤4·nand an increasing sequence of angles
0≤α1<α
2<...<α
k≤2πsuch that
P1(P, α)=
n
i=1
a1,i ·cos(φi+α)+b1,i ·sin(φi+α)ifα∈[α1,α
2]
n
i=1
a2,i ·cos(φi+α)+b2,i ·sin(φi+α)ifα∈[α2,α
3]
.........
n
i=1
ak−1,i ·cos(φi+α)+bk−1,i ·sin(φi+α)ifα∈[αk−1,α
k]
n
i=1
ak,i ·cos(φi+α)+bk,i ·sin(φi+α)ifα∈[αk,2π+α1],
where
{ai,j ,b
i,j 1≤i≤k, 1≤j≤k}⊂{+l2(ei),−l2(ei)},
or precisely, for any i∈{1,2,...,n}and any j∈{1,2,...,k}
aj,i =+l2(ei) if cos(φi+α)>0 for α∈(αj,α
j+1) (5)
aj,i =−l2(ei) if cos(φi+α)<0 for α∈(αj,α
j+1) (6)
and analogously,
bj,i =+l2(ei) if sin(φi+α)>0 for α∈(αj,α
j+1) (7)
bj,i =−l2(ei) if sin(φi+α)<0 for α∈(αj,α
j+1) (8)
What is important for us is
0<P1(P, α)=−P
1(P, α)ifα/∈{α1,α
2,...,α
k}
which implies that P1(P, α) does not have any local minimum inside the open
intervals
(α1,α
2),(α2,α
3), ..., (αk−1,α
k),(αk,2π+α1)).
In other words we have
min
α∈[0,2π]P1(P, α) = min {P1(P, α1),P1(P, α2), ..., P1(P, αk)}.(9)
A Rectilinearity Measurement for Polygons 755
Now, we are able to describe the following simple procedure for computing
R(P).
PROCEDURE R(P)Computation
Input: The vertices A1,A
2,...,A
nof a given ngon P.
1. Step.
For any i,i=1,2,...n, compute the angle φi, and compute the absolute
values of the following angle diﬀerences:
φi−π
2,φi−π,φi−3π
2,φi−2π.
Sort the above anglevalues in the increasing order and denote the sorted
values as: 0 ≤α1≤α2<...<α
k≤2π.
2. Step.
Assign either +l2(ei)or−l2(ei)toai,j and bi,j for any ifrom {1,2,...,n}
and any jfrom {1,2,...,k}
(in accordance with (5)(8) ).
3. Step.
Compute min
α∈[0,2π]P1(P, α) as the minimum of the ﬁnite number point set
{P1(P, α1),P1(P, α2), ... P1(P, αk−1),P1(P, αk)}
(in accordance with (9))
then compute R(P)as
R(P):= 4
4−π·
P2(P)
min
α∈[0,2π]P1(P, α)−π
4
(in accordance with Deﬁnition 1 ).
Output: R(P).
6 Some Examples and Concluding Remarks
The rectilinearity measure is applied to a (perfect) rectilinear polygon in the top
left hand polygon in Fig. 5 which is then degraded in various ways. The ﬁrst row
demonstrates the eﬀect of increasing levels of local noise applied to the polygon’s
vertices. In the second row the polygon is edited, eliminating vertices, which
eﬀectively rounds corners and increases its convexity. A shearing transformation
is applied in the third row. Finally, the polygon is warped, and the axis aligned
edges are increasingly rounded. All examples show that the rectilinearity measure
is well behaved; increasing distortion consistently decreases the computed value.
Note also that the orientations that maximised Q(P, α)= P2(P)
P1(P, α)match our
756 J. ˇ
Zuni´c and P.L. Rosin
1.000 0.849 0.334 0.041 0.038
0.860 0.813 0.603 0.508 0.277
0.668 0.516 0.425 0.380 0.351
0.748 0.457 0.287 0.204 0.134
Fig. 5. Examples of polygons with their rectilinearity measured as proposed in this
paper. Polygons are rotated to the orientations that maximised Q(P, α).
0.0 0.5 1.0 1.5
angle
0.02
0.00
0.02
Q(P,a)
0.0 0.5 1.0 1.5
angle
0.0
0.2
Q(P,a)
0.0 0.5 1.0 1.5
angle
0.2
0.0
0.2
Q(P,a)
0.0 0.5 1.0 1.5
angle
0.1
0.0
0.1
Q(P,a)
Fig. 6. Plots of normalised Q(P, α) for each of the rightmost examples in Fig. 5.
expectations except at high noise levels when the rectilinearity measure has
dropped close to zero. For each of the maximally degraded polygons (i.e. the
rightmost examples in each row) Fig. 6 plots Q(P, α). It can be seen that it
is well behaved and, despite the eﬀects of noise and other distortions which
introduce local maxima, the main peak remains distinct.
A second example is shown, working this time with real data from a Digital
Elevation Model (DEM), i.e. a depth map (see Fig 7 (a)). Some simple noise
ﬁltering and segmentation techniques were applied to produce a set of polygons.
These are further processed using Ramer’s line simpliﬁcation algorithm [10] to
reduce the eﬀects of quantisation since at a pixel level a dense 4connected curve
A Rectilinearity Measurement for Polygons 757
(a) (b)
Fig. 7. (a) A DEM of Hannover; (b) segmented regions with ﬁlled intensities propor
tional to rectilinearity
will be perfectly rectilinear! Fig 7 (b) plots the regions ﬁlled with intensities
proportional to their rectilinearity; thus rectilinear shapes should appear bright.
A casual glance seems to indicate that in some cases the computed rectilinearity
does not correspond well with human perception. As an example, the polygon
making up the central building in Fig 7 (a) only receives a value of 0.087 al
though it initially looks approximately rectilinear. Nevertheless, when plotted
again in Fig. 8 (a) at the orientation maximising Q(P, α) the coordinate frame
can be seen to be correctly determined. Moreover, the plot of Q(P, α) (Fig. 8 (b)
contains only the single main peak. In fact, the problem arises from errors in the
boundary due to the various steps in data processing. The deviations of local
edge orientation are substantial as demonstrated by a histogram of their orien
tation weighted by edge length. Fig. 8 (c) shows the histogram at two bin sizes,
and it can be seen that the distribution is fairly uniform, therefore producing a
low rectilinearity value.
As a possible means of reconciling this inconsistency between our perceptual
and measured evaluation of rectilinearity we note that relatively small adjust
ments to the polygon could greatly increase the values of Q(P). Thus we intend
to apply such a process, moving vertices such that they maximise Q(P) while
minimising the shift in vertex location. A similar scheme of “shape correction”
758 J. ˇ
Zuni´c and P.L. Rosin
(a)
0.0 0.5 1.0 1.5
angle
0.05
0.00
0.05
Q(P,a)
(b)
0123
angle
0
5
10
15
frequency
(c)
Fig. 8. (a) An example building rotated to maximise Q(P, α); (b) the corresponding
plot of Q(P, α); (c) histogram of length weighted edge orientation of (a).
has already been applied by Brunn et al. [1] who applied an iterative MDL vertex
shifting and removal scheme, and by Mayer [7] who used constrained snakes.
References
1. A. Brunn, U. Weidner, and W. F¨orstner. Modelbased 2dshape recovery. In
G. Sagerer et al, editor, Mustererkennung, pages 260–268. SpringerVerlag, 1995.
2. R.T. Collins, C.O. Jaynes, Y.Q. Cheng, X.G. Wang, F.R. Stolle, E.M. Riseman,
and A.R. Hanson. The ascender system: Automated site modeling from multiple
aerial images. Computer Vision and Image Understanding, 72(2):143–162, 1998.
3. S. Hyde et al. The Language of Shape. Elsevier, 1997.
4. R.M. Haralick. A measure for circularity of digital ﬁgures. IEEE Transactions on
Systems, Man and Cybernetics, 4:394–396, 1974.
5. R.B. Irvin and D.M. McKeown. Methods for exploiting the relationship between
buildings and their shadows in aerial imagery. IEEE Transactions on Systems,
Man and Cybernetics, 19(6):1564–1575, 1989.
6. Y.T. Liow and T. Pavlidis. Use of shadows for extracting buildings in aerial images.
Computer Vision, Graphics and Image Processing, 49(2):242–277, 1990.
7. S. Mayer. Constrained optimization of building contours from highresolution
orthoimages. In Proc. Int. Conf. Image Processing, 2001.
8. S. Noronha and R. Nevatia. Detection and modeling of buildings from multiple
aerial images. IEEE Transactions on Pattern Analysis and Machine Intelligence,
23(5):501–518, 2001.
9. D. Proﬃtt. The measurement of circularity and ellipticity on a digital grid. Pattern
Recognition, 15(5):383–387, 1982.
10. U. Ramer. An iterative procedure for the polygonal approximation of plane curves.
Computer Graphics and Image Processing, 1:244–256, 1972.
11. P.L. Rosin. Measuring rectangularity. Machine Vision and Applications, 11:191–
196, 1999.
12. M. Sonka, V. Hlavac, and R. Boyle. Image Processing, Analysis, and Machine
Vision. Chapman and Hall, 1993.
13. J. Willats. Art and Representation: New Principles in the Analysis of Pictures.
Princeton University Press, 1997.