• No results found

Geometric Templates from Spatial Relations

PROBLEMS

24.1. Defining a Brooks transform: Consider a 2D shape whose boundary is the curve Γ defined by x : I →R2 and parameterized by arc length. The line segment joining any two points x1 def

= x(s1) and x2 def

= x(s2) on Γ defines a cross-section of the shape, with length l(s1, s2) =|x1−x2|. We can thus reduce the problem of studying the set of cross-sections of the shape to the study of the topography of the surface S associated with the height function h : I2→R+defined by h(s1, s2) =12l(s1, s2)2. In this context, the ribbon associated with Γ can be defined (Ponce et al., 1999) as the set of cross-sections whose end-points correspond to valleys of S, (i.e., according to Haralick, 1983 or Haralick, Watson, and Laffey, 1983, the set of pairs (s1, s2) where the gradient ∇h of h is an eigenvector of the Hessian H, and where the eigenvalue associated with the other eigenvector of the Hessian is positive).

Let u denote the unit vector such that x1− x2 = lu. We denote by ti the unit tangent in xi (i = 1, 2), and by θi and κi, respectively, the angle between the vectors u and ti, and the curvature in xi. Show that the ribbon associated with Γ is the set of cross-sections of this shape whose endpoints satisfy

(cos2θ1− cos2θ2) cos(θ1− θ2) + l cos θ1cos θ21sin θ1+ κ2sin θ2) = 0.

Solution If v is a unit vector such that u and v form a right-handed orthonornal coordinate system for the plane, we can write ti = cos θiu+ sin θiv and ni =

− sin θiu+ cos θivfor i = 1, 2. The gradient of h is

∇h =

µt1· (x1− x2)

−t2· (x1− x2)

= l

µ cos θ1

− cos θ2

¶ ,

and its Hessian is H =

µ1 + κ1n1· (x1− x2) −t1· t2

−t1· t2 1− κ2n2· (x1− x2)

=

µ1− lκ1sin θ1 − cos(θ1− θ2)

− cos(θ1− θ2) 1 + lκ2sin θ2

¶ .

We now write that the gradient is an eigenvector of the Hessian, or if “×” denotes the operator associating with two vectors in R2 the determinant of their coordi-nates,

0 = (H∇h) × ∇h

= l2

µ (1− lκ1sin θ1) cos θ1+ cos θ2cos(θ1− θ2)

− cos θ1cos(θ1− θ2)− (1 + lκ2sin θ2) cos θ2

×

µ cos θ1

− cos θ2

¶ ,

100

101

which simplifies immediately into

(cos2θ1− cos2θ2) cos(θ1− θ2) + l cos θ1cos θ21sin θ1+ κ2sin θ2) = 0.

24.2. Generalized cylinders: The definition of a valley given in the previous exercise is valid for height surfaces defined over n-dimensional domains and valleys form curves in any dimension. Briefly explain how to extend the definition of ribbons given in that exercise to a new definition for generalized cylinders. Are difficulties not encountered in the two-dimensional case to be expected?

Solution Following the ideas from the previous exercise, it is possible to define the generalized cylinder associated with a volume V by the valleys of a height function defined over a three-dimensional domain: for example, we can pick some parameterization Π of the three-dimensional set of all planes by three parameters (s1, s2, s3), and define h(s1, s2, s3) as the area of the region where V and the plane Π(s1, s2, s3) intersect. The valleys (and ridges) of this height function are charac-terized as before by (H∇h) × ∇h = 0, where “×” denotes this time the operator associating with two vectors their cross product. They form a one-dimensional set of cross-sections of V that can be taken as the generalized cylinder description of this volume.

There are some difficulties with this definition that are not encountered in the two-dimensional case: In particular, there is no natural parameterization of the cross-sections of a volume by the points on its boundary, and the valleys found using a plane parameterization depend on the choice of this parameterization. More-over, the cross-section of a volume by a plane may consist of several connected components. See Ponce et al. (1999) for a discussion.

24.3. Skewed symmetries: A skewed symmetry is a Brooks ribbon with a straight ax-is and generators at a fixed angle θ from the axax-is. Skewed symmetries play an important role in line-drawing analysis because it can be shown that a bilaterally symmetric planar figure projects onto a skewed symmetry under orthographic pro-jection (Kanade, 1981). Show that two contour points P1and P2forming a skewed symmetry verify the equation

κ2

κ1 =−

·sin α

2

sin α1

¸3 ,

where κidenotes the curvature of the skewed symmetry’s boundary in Pi(i = 1, 2), and αi denotes the angle between the line joining the two points and the normal to this boundary (Ponce, 1990).

Hint: Construct a parametric representation of the skewed symmetry.

Solution Given two unit vectors u and v separated by an angle of θ, we param-eterize a skewed symmetry by

½ x1= sv− r(s)u, x2= sv + r(s)u,

where u is the generator direction, v is the skew axis direction, and x1 and x2 denote the two endpoints of the ribbon generators. Differentiating x1and x2with respect to s yields

½ x01= v− r0u, x02= v + r0u,

102 Chapter 24 Geometric Templates from Spatial Relations

and ½

x001=−r00u, x002= r00u.

Let us define αi as the (unsigned) angle between the normal in xi (i = 1, 2) and the line joining the two points x1and x2. We have





sin α1= 1

|x01||u × x01| = sin θ

p1− 2r0cos θ + r02, sin α2= 1

|x02||u × x02| = sin θ

p1 + 2r0cos θ + r02,

where “×” denotes the operator associating with two vectors inR2the determinant of their coordinates.

Now remember from Ex. 19.4 that the curvature of a parametric curve is κ =

|x0 × x00|/|x0|3. Using the convention that the curvature is positive when the ribbon boundary is convex, we obtain





κ1= − r00sin θ (1− 2r0cos θ + r02)3/2, κ2= r00sin θ

(1 + 2r0cos θ + r02)3/2, and the result follows immediately.

Programming Assignments

24.4. Write an erosion-based skeletonization program. The program should iteratively process a binary image until it does not change anymore. Each iteration is divided into eight steps. In the first one, pixels from the input image whose 3× 3 neigh-borhood matches the left pattern below (where “*” means that the corresponding pixel value does not matter) are assigned a value of zero in an auxiliary image; all other pixels in that picture are assigned their original value from the input image.

0 0 0

* 1 *

1 1 1

0 0

0 1 1

1 1

*

*

The auxiliary picture is then copied into the input image, and the process is re-peated with the right pattern. The remaining steps of each iteration are similar and use the six patterns obtained by consecutive 90-degree rotations of the original ones. The output of the program is the 4-connected skeleton of the original region (Serra, 1982).

24.5. Implement the FORMS approach to skeleton detection.

24.6. Implement the Brooks transform.

24.7. Write a program for finding skewed symmetries. You can implement either (a) a naive O(n2) algorithm comparing all pairs of contour points, or (b) the O(kn) projection algorithm proposed by Nevatia and Binford (1977). The latter method can be summarized as follows: Discretize the possible orientations of local ribbon axes; for each of these k directions, project all contour points into buckets and verify the local skewed symmetry condition for points within the same bucket only;

finally, group the resulting ribbon pairs into ribbons.

C H A P T E R 25

Application: Finding in Digital