Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
A (and B) of a (and b) are defined using the usual discrete z1 , . . . , zn , where zj = ei n . Clearly, we have zn = 1
Fourier transform. Specifically, each Ak is a vector in C3 and zj = z1j , j = 1, . . . , n. Finally, we denote the trans-
Pn 2πjk
pose of a matrix M by M T , the conjugate by M , and the
given by Ak = j=1 aj e−i n , where k = 1, . . . , n. The
set of Ak ’s are referred to as the FD coefficients of a. conjugate transpose by M ∗ .
In this paper, we define the similarity distance between 3.1. The midpoint smoothing operator
a and b as the minimum of the following L2 measure:
v Let a be the original 3-D contour, i.e., a closed poly-
u
uX n 3 gon, with n vertices. The midpoint polygon a0 of a is the
u X
µ(A, B) = t wk |Ak,j − Bk,j |2 , (1) polygon obtained by connecting the midpoints of all the line
k=1 j=1 segments of a in order. The midpoint smoothing operation
can be captured by the n-th order midpoint smoothing op-
under arbitrary translation, scale, rotation of the contours, erator Sn , with a0 = Sn a. The operator Sn is an n × n
and vertex shifts, where | · | denotes the norm of a complex matrix whose ij-th entry is 1/2 if j = i or j = i + 1 mod n,
number. Of course, the FD coefficients will be derived in a and 0 otherwise.
different way using our NFD approach. It is interesting to note that Sn is invertible if and only
The weights wk can be chosen in a variety of ways. For if n is odd. For any odd number n, Sn−1 has 1’s all along
example, noise tolerance can be achieved by setting wk = 0 its main diagonal, and all along the diagonal below. In all
whenever the k-th FD coefficient captures a high frequency other diagonals, the entries alternate between 1 and -1. So
it makes sense to call these midpoint polygons the midpoint 3.3. FDs with respect to our smoothing operator
signatures, at different smoothness levels, of the original Since the eigenvectors z1 , . . . , zn form a basis, any
polygon. polygon a has an eigen-decomposition
Midpoint smoothing is closely related to uniform Lapla-
n
X
cian smoothing [16]. After one step of Laplacian smoothing
a= zj Aj (3)
of the polygon a, we yield the vertex transformation
j=1
1 1 1 with respect to our midpoint smoothing operator, where
a0j = aj−1 + aj + aj+1 . (2)
4 2 4 each Aj , an FD coefficient, is a uniquely determined 3-D
It is easily seen that two steps of midpoint smoothing corre- vector in C3 . To evaluate Ak , for k = 1, 2, . . . , n, multiply
sponds to one step of Laplacian smoothing. This connection both sides of (3) by z∗k /n. We have
n n
helps us obtain a geometric interpretation of the frequencies 1 ∗ 1 X kj 1X 2πkj
associated with the FD coefficients we derive later. Ak = zk a = z 1 aj = aj e−i n , (4)
n n j=1 n j=1
We choose to use the midpoint smoothing operator to
construct an eigen-decomposition since, as we shall see in which is precisely the traditional discrete Fourier transform
the following sections, the eigenvectors of our smoothing of a. Note that if the Laplacian smoothing operator [16]
operator has a simpler form, and it corresponds exactly to is used instead, we would arrive at a different form for the
the traditional discrete Fourier transform. transform. Pn
3.2. Eigenproperties of the smoothing operator When k = n, we have An = n1 j=1 aj ∈ R3 , giving
the centroid of all the vertices. For k < n, we can view
The behavior of midpoint smoothing can be analyzed an FD coefficient Ak = [rx + gx i, ry + gy i, rz + gz i],
according to the eigenproperties of the smoothing opera- as a pair of 3-D vectors (rx , ry , rz ) and (gx , gy , gz ). Later
tor. We now state some of the properties we need for later on, we shall reduce the problem of normalizing FDs to the
development, and leave out their proofs, since they fairly problem of aligning these 3-D vectors.
straightforward.
Let us first assume that n, the number of vertices in the 3.4. Frequencies associated with FD coefficients
polygon a, is odd, and recall that z1 , . . . , zn denote the n- Consider a non-degenerate polygon a for which there is
th roots of unity. Then the eigenvalues of the n-th order a scalar λ such that (I − Sn2 )a = λa, where I is the identity
midpoint smoothing operator Sn are matrix. Such a polygon is called an eigenpolygon, and the
scalar λ is said to be its frequency. By (2), we have λak =
1 + zj jπ jπ jπ jπ jπ
λj = = cos2 + i sin cos = cos ei n , ak − Sn2 ak = ak − a0k . It follows that |ak − a0k | = |λ| · |ak |.
2 n n n n The distance between ak and a0k is a discrete approximation
for j = 1, . . . , n. For each j, an eigenvector of Sn corre- of the Laplacian at ak , as shown in Figure 2.
sponding to λj is ak
zj = [zj zj2 . . . zjn ]T = [z1j z12j ... z1nj ]T .
Therefore, they form a basis of the complex n-dimensional Figure 2. Discrete Laplacian at a vertex ak .
space. Furthermore, if we use Zn to denote the matrix of
eigenvectors, Zn = [z1 z2 . . . zn ], then the inverse of Zn Geometrically, the higher the frequency λ, the larger the
is given by Zn−1 = Z ∗ /n. If the eigenvectors are normal- discrete Laplacians at the vertices, and the larger the oscil-
ized, then Zn becomes unitary. lation along the polygon. If a is a polygon with the eigen-
If n is even, then we have λj = (1 − zj )/2 and the cor- decomposition (3), then (I − Sn2 )zj Aj = (1 − λ2j )zj Aj ,
responding eigenvector zj = [zj −zj2 zj3 . . . −zjn ]T , with for each j. It follows that the real part of zj Aj gives
the signs of the vector entries alternating. It turns out that an eigenpolygon, and the larger the magnitude of λj , the
the parity of n does not affect any of our results or the way lower its corresponding frequency. Therefore, the lowest
our matching algorithm works. In particular, the unitarity frequency zero corresponds to the eigenvalue λn = 1, and
of the matrix Zn still holds if n is even. So in the rest of our the next two lowest frequencies correspond to the eigenval-
π π
discussions, let us assume that n is odd. ues λ1 = cos nπ ei n and λn−1 = cos nπ e−i n .
3.5. Convergence to planarity A1 = (p − qi)/n and An−1 = (p + qi)/n, the normal-
ization problem can be reduced to the alignment of the two
It can be shown that even with a uniform dilation, the
vectors p and q to some reference frame. In the context of
vertices of the midpoint polygons reach planarity. A precise
shape matching, we are given two contours a and b having
statement of this is given by the following theorem. Due to
the spanning vectors {pa , qa } and {pb , qb } of their respec-
a lack of space, we are not able to include the proof [22] of
tive limit plane, we need to align the two pairs of vectors
the theorem in this paper. For simplicity, let us assume that
optimally under vertex shift and rotation.
An = 0 in (3); that is, the centroid of the polygon vertices
An obvious optimality criterion is to minimize the sim-
remains at the origin.
ilarity distance (1). But even with the vertex orders fixed,
Theorem: If, after each iteration of midpoint smoothing, finding the optimal rotation is a complex non-linear prob-
the new polygon vertices are dilated away from the origin lem. To solve the alignment problem efficiently, we observe
by a factor of 1/ cos πn , then the vertices of the midpoint that although the spanning vectors are not preserved under
polygons approach the plane spanned by the 3-D vectors vertex shift, the limit plane is! Regardless of the vertex or-
n
X n
X dering, midpoint smoothing produces the same sequence of
2jπ 2jπ midpoint polygons. Therefore, we complete the normaliza-
p= aj cos and q = aj sin .
j=1
n j=1
n tion by aligning both limit planes with the xy-plane.
Since the limit plane represents an “average plane” for
As we can see, the limit plane is completely determined the contour vertices, our approach also has a nice geometric
by the original polygon. The key observation we make is interpretation. Limit plane alignment is accomplished by
that the directions of p and q coincide with that of the two finding a rotation which aligns the plane normal with the
3-D vectors corresponding to the dominant FD coefficient z-axis exactly. This is a standard practice in vector algebra,
n and can be done in constant time [22].
1 X −j
A1 = z aj
n j=1 1 4.2. The matching algorithm
The input to our algorithm consists of two closed 3-D
Xn Xn
1 2jπ 1 2jπ polygons with the same number of vertices. In practice,
= aj cos − aj sin i
n j=1 n n j=1 n if two curves to be matched do not have the same number
of sample points, or the noise in the samples is too great,
p − qi
= . appropriate preprocessing steps may be applied. We shall
n discuss this in Section 4.2.2.
The same holds for An−1 , with An−1 = (p+qi)/n. Recall
4.2.1 Overview of the algorithm
that A1 and An−1 are associated with the lowest non-zero
frequency, and together, they quantify the dominant shape The matching algorithm can be summarized as follows,
characteristic of the polygon. We shall use this fact for our where a and b are the input polygons, each having n ver-
FD normalization. tices, and k is the number of FD coefficients used for mea-
suring similarity.
4. Matching 3D contours using NFDs
1. Compute A and B, the FDs of a and b. [O(kn), or
In this section, we first describe our notion of normalized O(n log n) with Fast Fourier Transform (FFT).]
Fourier descriptors, or NFDs, for 3-D contours. We perform
normalization with respect to centroid, scale, and more cru- 2. Centroid and scale normalization. [O(n)]
cially, the two dominant FD coefficients. Then we present 3. Apply rotations to align the limit planes with the xy-
our shape matching algorithm, analyze its complexity, and plane. [O(1); note that the spanning vectors are avail-
reason about its effectiveness. able from A1 and B1 , which are already computed.]
4.1. Normalized FDs for 3-D contours
4. For each shift j of the vertices in b, 0 ≤ j ≤ n − 1,
Normalization with respect to centroid and scale is compute Bj , the FD of b after the shift and a rotation
straightforward [19]. This is accomplished by first translat- which aligns the major axes of a and b optimally in the
ing the polygon so that the centroid of the vertices is at the xy-plane. [O(kn); we will explain this step in Sec-
origin, i.e., transform An to 0. Next, the coordinates of the tion 4.2.3.]
vertices are divided by the magnitude of A1 , the dominant
FD coefficient, to normalize scale. 5. The similarity distance returned is the minimum of the
Then, we normalize with respect to the next dominant L2 metric µ(A, Bj ), j = 0, . . . , n − 1, defined in (1)
shape characteristics, captured by A1 and An−1 . Since with w1 = w2 = . . . = wn = 1.
(j)
4.2.2 Preprocessing and qb are embedded in Bj,1 , no extra computation is re-
quired. Similarly, the major axis {pa , qa } of a is already
Like all other FD-based approaches for similarity compu-
computed in A0,1 . We then find the vector ha which bisects
tations [12, 19, 21], the result of our matching algorithm
the angle between pa and qa in the xy-plane. The angle
could be sensitive to the sampling of the input curves. A (j)
similarity distance greater than zero may be reported for two bisector hb is defined in the same way. It should be in-
identical curves that are only sampled differently. tuitive to see that the optimal rotation angle is simply the
(j)
To remedy this problem, we propose the use of uniform angle between ha and hb , as shown in Figure 3. All these
resampling before running the matching algorithm. We can operations can be performed in O(1) time.
not only ensure that the input polygons have the same num-
ber of vertices, this number can also be chosen as a power of q (j)
b
2, so that FFT is applicable. Making the sampling uniform h (j)
b
should have an added advantage since midpoint smoothing p
a
does assume a uniform parameterization.
p (j)
Besides uniform resampling, a polygonal curve simplifi- h b
a
cation algorithm can also be applied to reduce quantization
q
or measurement noise. Obviously, the effectiveness of the a
resampling or simplification algorithm should have a great
influence on the overall performance of our shape match- Figure 3. Aligning major axes in the xy-plane.
ing algorithm. But discussions on choosing the appropri-
ate sampling rate or simplification criteria are beyond the Let R denote the rotation matrix associated with the op-
scope of this paper. We simply assume that after proper timal rotation angle. By linearity of the Fourier transforms,
preprocessing, the input polygons have the same number of the FDs for a rotated polygon can be obtained from a ro-
vertices, and they capture the shapes of the original input tated version of the FDs of the original polygon. Since R is
curves sufficiently well. 3 × 3, computing the final Bj takes time O(k).
4.2.3 The optimal shift and rotation combination 4.3. Summary
Given two closed polygons a and b with their FDs A0 and Our shape matching algorithm is invariant under transla-
B0 normalized, we show how to find the optimal shift and tion, scale, rotation, and vertex shift; it returns zero if and
rotation combination for b to match its major axes with a in only if one input polygon is a transform of the other. Our
time O(kn), where n and k are as defined in the algorithm algorithm is efficient, simple to describe, and easy to imple-
in Section 4.2.1. Note that both major axes lie in the xy- ment, and the similarity distance computed is a metric.
plane after normalization. The best time complexity for an FD-type matching algo-
Suppose that we fix the vertex shift j. Then it is sufficient rithm is O(n log n), since computing the FDs using FFT
to show that computing Bj , the FD of b after the shift and alone takes that much time. To achieve this, it is suffi-
a rotation which aligns the major axes optimally in the xy- cient to find an appropriate measure of the “aligned-ness”
plane, takes time O(k). between two pairs of 3-D vectors, where the length of the
Pnthe m-th2πmlFD coefficient of the polygon b is
By (4), spanning vectors and the subtended angles are both consid-
B0,m = l=1 bl e−i n . After a vertex shift of j, we have ered. Also, the measure should be correlated with the simi-
the following with arithmetic modulo n, larity distance between the input contours, but much easier
to minimize. We are still working towards this goal.
n
X n
X
2πml 2πjm 2πm(l+j)
Bj,m = bl+j e−i n = ei n bl+j e−i n
(a) (b)
(a) (b)
(c) (d)
0.6
0.6
0.4
0.4
0.2
0.2
0 0
0 10 20 30 40 50 60 70 80 90 100 110 0 10 20 30 40 50 60 70 80 90 100 110