Contributions to Relative Position Descriptor Computation in the case of Vector Objects

by Jason Kemp

A Thesis presented to The University of Guelph

In partial fulfilment of requirements for the degree of Master of Science in Computer Science

Guelph, Ontario, Canada c Jason Kemp, May, 2019 ABSTRACT

Contributions to Relative Position Descriptor Computation in the case of Vector Objects

Jason Kemp Advisor: University of Guelph, 2019 Dr. Pascal Matsakis

Two new algorithms are introduced, both related to Relative Position Descriptors (RPDs) in the case of vector objects. The first, The Great Circle distribution, presents a new spherical point distribution. This algorithm distributes points over the surface of a sphere, ensuring points lie on the minimum number of great circles possible, while keeping the points distributed evenly. Multiple evenness measures are used to compare evenness with multiple common spherical point distribution techniques. This distribution is designed as a direction set for 3D RPDs, where each point represents a direction, and will improve the efficiency of 3D vector RPDs. The second new algorithm builds on the φ-descriptor, a recent RPD. In this paper the first algorithm to calculate the φ-descriptor for 2D vector objects is proposed and tested. The results are compared against the existing 2D raster φ-descriptor. The new algorithm is intended to show the versatility of the φ-descriptor. Table of Contents

Abstract II

1 Introduction 1 1.1 Relative Position Descriptors ...... 1 1.2 Direction Sets ...... 2 1.3 Thesis Statement ...... 3 1.4 Motivation and significance ...... 3 1.5 Thesis Overview ...... 4

2 Background and Literature Review 5 2.1 Relative Position Descriptors ...... 5 2.1.1 Existing RPDs ...... 5 2.1.2 The Force Histogram ...... 6 2.1.3 The PHI-Descriptor ...... 6 2.1.4 Similarity Measures ...... 9 2.2 Even Distribution of points on a Sphere ...... 11 2.2.1 Existing Distributions ...... 11 2.2.2 Distributions used in Comparative Study ...... 13 2.2.3 Evenness Measures ...... 15

3 Direction Sets for Force Histogram Computation in the case of 3D Vector Objects 20 3.1 Variant ...... 20 3.1.1 Motivation ...... 20 3.1.2 Formulation ...... 25 3.1.3 Solution ...... 25 3.2 Comparative Study ...... 28 3.2.1 Evenness Results ...... 28

3.2.2 More on Gn vs. Cn ...... 34 3.3 Conclusion ...... 37

III 4 PHI-Descriptor Computation in the case of 2D Vector Objects 39 4.1 Algorithm ...... 39 4.1.1 Points of Interest ...... 40 4.1.2 Find Ray Intersections ...... 42 4.1.3 Point in Polygon Test ...... 45 4.1.4 Create Rays ...... 46 4.1.5 Create Phi Regions ...... 50 4.1.6 Rotation ...... 54 4.1.7 Build Descriptor ...... 55 4.2 Implementation ...... 55 4.2.1 Input and Output ...... 56 4.2.2 Data Structures ...... 56 4.2.3 Visual Output ...... 58 4.2.4 Testing During Implementation ...... 58 4.3 Experiments ...... 58 4.3.1 Test Data ...... 59 4.3.2 Convert to Raster Objects ...... 60 4.4 Results ...... 63 4.4.1 Limitations ...... 70 4.5 Conclusion ...... 71 4.5.1 Future Work ...... 71

5 Conclusions and future work 73 5.1 Conclusions ...... 73 5.2 Future work ...... 74

Bibliography 75

IV Chapter 1

Introduction

In this chapter we introduce the topics of Relative Position Descriptors (section 1.1) and Direction Sets (Section 1.2). A thesis statement is provided in Section 1.3. The motivation for the work is described in Section 1.4. And Section 1.5 provides an overview of the layout of the thesis.

1.1 Relative Position Descriptors

A Relative Position Descriptor (RPD) provides a quantitative description of the spatial position of two image objects with respect to each other. Robot navigation, GIS, linguistic scene description, and medical imaging are some areas that can benefit from RPDs. A descriptor can, for example, give a quantitative answer to the question: “Is object A to the left of object B?”. It may indicate whether A is exactly to the left, not at all to the left, or to some degree to the left of B. There are many RPD algorithms designed for raster objects, i.e., sets of pixels (2D case) or voxels (3D case). There are significantly fewer RPD algorithms de- signed for use with vector objects, i.e., sets of vertices defining polygons (2D case) or polyhedra (3D case). This thesis focuses on RPD algorithms in the case of vector objects. Two RPDs are considered: the force histogram and the φ-descriptor. The force histogram, introduced in 1999, has been established in research as a powerful RPD. Algorithms exist to compute the force histogram in the case of 2D raster objects, 2D vector objects, 3D raster objects and 3D vector objects - although the algorithms

1 for 3D objects are computationally inefficient. A much more recent RPD, the φ- descriptor, introduced in 2015, encapsulates much more relative position information than the force histogram, and appears to be much more powerful. An algorithm exists to compute the φ-descriptor in the case of 2D vector objects, but none yet for the case of 2D vector objects, or 3D objects.

1.2 Direction Sets

One common trait among RPDs is the need to calculate one or more values over multiple directions in space. A natural set of reference directions in the 2D space is

2π 2π 2π the set {0, k , 2 k , ..., (k − 1) k } where k is the number of directions. This direction set can be pictured as a set of points evenly distributed on the unit circle, where each point indicates a direction from the center of the circle. When calculating a RPD for 3D objects, a 3D direction set is required. The 3D direction set can be pictured as a set of points evenly distributed across a unit sphere, where each point indicates a direction from the center of the sphere. This is a well known problem and several solutions have been proposed, but none with the aim to aid in the computation of 3D RPDs. For example, the computation of the force histogram of a pair of 3D vector objects comes down to the computation of the force histogram of multiple pairs of 2D vector objects, where each pair of 2D objects is obtained by slicing the 3D objects with a plane. Slicing the 3D objects repeatedly is computationally expensive. However if multiple reference directions exist on a single plane, i.e., on a single great circle around the unit sphere, then the same pair of 2D objects can be used towards the computation of the 3D force histogram in all these directions, i.e., slicing can be drastically reduced.

2 1.3 Thesis Statement

While there exist several even spherical point distributions, none are designed as a 3D reference direction set for 3D RPDs. Currently there exists an algorithm for calculating the φ-descriptor of 2D raster objects, but there is no algorithm for calculating the φ-descriptor of 2D vector objects. A variation to the problem of distributing points evenly on a sphere is presented along with a first solution; the variation has additional con- straints to optimize its solution as a 3D reference direction set and speed up force histogram computation in the case of 3D vector objects. Also in this thesis, the first algorithm to calculate the φ-descriptor of 2D vector objects is presented and tested.

1.4 Motivation and significance

An algorithm to compute the force histogram in the case of 3D vector objects exists, yet no optimal direction set existed for its computation. The algorithm could be improved upon, potentially as well as future 3D RPD algorithms, using a direction set designed for this purpose. The new direction set presented in this thesis is designed specifically to improve on these computation times. The φ-descriptor was created recently, and appears to be much more versatile than the other RPDs. The results in this thesis are evidence of this versatility: it has been shown that the φ-descriptor encapsulates much more spatial relationship information than the force histogram [1] [2]; it is shown here, that like the force histogram, it is able to handle vector objects.

3 1.5 Thesis Overview

Chapter 2 explores the background of RPDs and even distribution of points on a sphere. Chapter 3 explores a first algorithm to calculate direction sets for use with 3D RPDs. Chapter 4 looks at a new algorithm to extend the φ-descriptor to work with vector objects, rather than just raster objects. Conclusions and future work are found in Chapter 5.

4 Chapter 2

Background and Literature Review

In this chapter we look at existing work in RPDs in Section 2.1, as well as methods to compare how similar two φ-descriptors are, Section 2.1.4. We then look at methods to evenly distribute points on a sphere in Section 2.2, as well as methods to measure how even a distribution is, Section 2.2.3.

2.1 Relative Position Descriptors

RPDs provide a quantitative description of the spatial relations between objects. These spatial relations can be categorized as direction, topology, distance, and sur- rounds. Freeman [3] was the first to suggest that the spatial relations could be used to model relative position. He also suggested that a fuzzy system be used to allow for these relations to be given a degree of truth. Miyajima and Ralescu [4] proposed that an RPD could be created to represent these models of spatial relations. RPDs are visual descriptors, other visual discriptors include color, texture and shape descrip- tors [5]. Robot navigation, GIS, linguistic scene description, and medical imaging are some areas that can benefit from RPDs [5].

2.1.1 Existing RPDs

Many RPDs exist, and have built upon, and improved, on each other over time. The Angle Histogram is called the first true RPD [5]; it is able to give a directional relation such as “to the right of”, “above” etc, [6] [7] [8] [4]. The Force Histogram, (a member of the F-Histogram family [9]) can be used to generalize the angle histogram,

5 and also improve upon it [10]. Similarly, the recently introduced φ-descriptor [11] can be used to generalize the force histogram, and also model additional relations. While the angle and force histogram can model directional relations, there are others such as the R Histogram and the Allen Histogram that can also model distance and topology respectively [5]. The φ-descriptor models direction, topology, distance, and surrounds relations [1] [2], meaning it can describe a larger set of relations than any other existing RPD. Allen Histograms [12] and the φ-descriptor can be considered as a set of F-Histograms [13]. A more in depth review of RPDs is available in [5].

2.1.2 The Force Histogram

The force histogram determines the sum of all forces a pair of objects enact on one another. For each direction in a direction set a value is assigned representing that force. Matsakis provided algorithms to calculate the Force Histogram RPD for the case of 2D vector objects [14] [15], as well as 3D vector objects [16]. In the case of 2D vector objects; at each vertex or intersection between the two objects, a horizontal line partitions the objects into trapezoidal pieces. The areas of these pieces are determined and used to form the value of the descriptor in a single direction. The objects are then rotated to the next direction in a direction set. This process is repeated for each direction. For 3D a similar approach is used, however a plane is used to intersect the 3D objects to define a 2D subset of the objects. The 2D algorithm is then applied to the resulting objects.

2.1.3 The PHI-Descriptor

For each direction in a direction set, the φ-descriptor algorithm divides the ob- jects into subregions (Phi Regions); each Phi Region corresponds to an elementary spatial relationship. The area and length of each Phi Region are determined, and the values that correspond to the same group of spatial relationships (Phi Group) are summed. This information is combined to form a meaningful description of the

6 relative position between the objects in the image in a single direction. This process is repeated in many directions to form the complete φ-descriptor. Figure 2.1 may help to visualize this process. The descriptor can be conceptualized as a set of histograms, one for each Phi Group, with the directions as bins, and the size in that direction the value in that bin.

Figure 2.1: On the left, the original image with two intersecting objects. In the middle, that image divided into Phi Regions. On the right, an example of a histogram showing the Trails relation in multiple directions.

Phi Groups

An important aspect of this algorithm we refer to as Phi Groups. These are groups of elementary spatial relations, each group shares some characteristic, often described by the verb naming the group. For example the overlaps group contains all relations where two objects overlap one another. The trails group contains all relations where there is a gap between the two objects, ie one object trails behind the other. Each group, along with the elementary spatial relations that they consist of, can be seen in Table 2.2. One of the core elements of the algorithm is to find regions, Phi Regions, that correspond to a single Phi Group.

7 .

Figure 2.2: Phi Groups. The Groups marked with an asterisk are currently not capable of being recognized by the implementation for the Phi Descriptor in the case of 2D vector Objects. This will be discussed further in Sections 4.4.1 and 5.2

8 PHI Descriptor

The resulting descriptor is a matrix of numbers, a column for each direction, and a pair of rows for each Phi Group, an example can be seen in Table 2.1. The pair of rows represent two size measurements, area and height. Each element of the matrix represents the sum of the sizes of all Phi Regions sharing a Phi Group in a single direction. For example, if there are two regions with the trails Phi Group in direction θ then the cells for trails in direction θ would contain the sum of the two sizes, one for the sum of the areas, and one for the sum of the heights. In addition to the Phi Groups, the first two rows of the descriptor show the size of the Region of Interaction as W area and W length (further explained in Section 4.1.4). These two values represent the sum of the sizes of all Phi Regions in the direction.

2.1.4 Similarity Measures

Two similarity measures are used to compare the similarity of φ-descriptors d1 and d2. MinMax and SubAdd are based on those provided in the software package for the 2D raster φ-descriptor. The similarity measures each require that d1 and d2 use the same direction set, and that all values are nonnegative. The values from one descriptor are compared against their counterpart in the other descriptor; the pair of values d1(u) and d2(u) would refer to the same element in each descriptor (ex. trails area in direction θ).

MinMax Similarity

The MinMax of the two descriptors is a ratio between the sum of the maximum

9 Direction 0 5 10 ... Phi Group W area 310009 311138 309000 ... W length 516.681667 533.891447 549.504068 ... V area 404 234 17 ... V length 202 36.137514 0.986414 ... A area 7769 7819 7815 ... A length 75.062802 70.710516 63.484472 ... R area 7863 9200 10506 ... R length 129.966942 120.720817 122.621517 ... T area 7481 10461 13798 ... T length 124.683333 129.641473 136.027732 ......

Table 2.1: An example of part of a φ-descriptor. There were 72 directions used, in this example the sum of the areas of the Phi Regions corresponding to the trails (T area) Phi Group in direction 5 is 10461.

10 and the sum of the minimum for each pair of values:

P min(d1(u), d2(u)) (2.1) P max(d1(u), d2(u)) The MinMax similarity is 1.0 if both descriptors are identical, and lower values indicate less similarity.

SubAdd Similarity

The SubAdd of the two descriptors is a ratio between the total of the sums and the total of the differences for each pair of values:

P |d1(u) − d2(u)| 1 − (2.2) P |d1(u) + d2(u)| The SubAdd similarity is 1.0 if both descriptors are identical, and lower values indicate less similarity.

2.2 Even Distribution of points on a Sphere

The problem of finding an even distribution of an arbitrary number of points over a sphere has attracted the attention of a wide variety of researchers (e.g., computer scientists, mathematicians, biologists, chemists, physicists, astronomers, architects), and it is of importance to a wide variety of applications (e.g., the mapping of the Earth’s gravitational field, the study of molecular systems, the modelling of viruses, the design of geodesic domes) [17] [18].

2.2.1 Existing Distributions

Many different criteria for point distribution can be found in the literature. A common approach is to optimize some function of the positions of the points on the

11 sphere. Most of these optimization problems have become classical unsolved mathe- matical problems [19]. There are usually many local optima, but the global optima remain unknown. As an example, one may want to see the points as that repel each other with a force given by Coulomb’s law and determine the minimum energy configuration; this is the Thomson problem [20]. Practically, points are first randomly generated on the sphere, and then an iterative process allows a stable con- figuration to be found. For example, Bourke uses hill climbing [21], while Semechko uses a more efficient adaptive Gauss-Seidel update scheme [22]. Such optimization algorithms can easily be adapted to generate distributions with antipodal symme- try [23] [24], a property which is useful in many applications, especially in the field of medical imaging [25] [26]. While the Thomson problem seeks to minimize the Coulomb forces, the Tammes problem seeks to maximize the pairwise distance be- tween the points [27]. Neither of these problems yet have a general solution. To achieve a similar angle between points on a sphere rather than a circle, the number of directions increases by orders of magnitude. For example 30 points even

2π placed around a circle are spaced by 30 while this would take aboiut 300 points on a sphere. When a very large number of points are required, the iterative methods may become unwieldy. For this reason many non-iterative methods have been devised, such as placing points along a spiral curve starting at the “south pole” of the sphere and rotating up and around to the opposing “pole” [28] [29] [30] [17]. Rather than a spiral, other curves are possible, e.g., equidistant latitude circles [31]. Another common approach is geodesic subdivision: “start with an (8 congruent triangular faces) or (20 congruent triangular faces), place a point at the midpoint of each edge and normalize the coordinates of each new point to ‘push’ it out to the surface of the sphere, and keep repeating until the desired number of points is attained” [32]. The octahedron can be used to generate distributions with 2 + 4k points while the icosahedron can be used to generate distributions with 2 + 5 × 22k−1 points, where k is a positive integer.

12 Constraints can be placed on these distributions for specific needs for example antipodally symmetric even distributions, i.e., even distributions that are invariant under inversion through the centre of the sphere, are of special importance in medical imaging [26] [33] [23] [25] and have been found useful in other areas, including astro- physics [34] and optical sciences [35]. These distributions may be generated through direct methods [31], but iterative methods are far more common [24] [23] [36].

2.2.2 Distributions used in Comparative Study

Six distributions of n points over a sphere are considered in this paper: Wn,Tn,Bn,Kn,Gn and Cn. See Table 2.2 and Fig. 2.3 for their main characteristics. These distributions will be tested in Section 3.2.

Wales’ distribution, Wn, is the distribution obtained by Wales et al. using the basin-hopping optimization algorithm, as described in [37] [38]. The aim of the au- thors was to generate strong candidates for global minima of the Thomson problem, i.e., for distributions with the lowest possible energy. The values considered for n were all the integers between 10 and 400, as well as selected integers between 400 and 4352.

Tn is the tailored distribution. It is obtained through a simple optimization algo- rithm comparable to Bourke’s [21] and inspired by the formulation of the Thomson problem. See Fig. 2.4. The particularity of the algorithm is that it strives to output a distribution that is as even as possible, i.e., the distribution depends on the even- ness measure to be used for its assessment: when the measure is the energy, a rough solution to the Thomson problem is obtained; when the measure is the separation distance, a rough solution to the Tammes problem is obtained; etc. The algorithm is not as efficient or effective as, e.g., the algorithm used to build Wales’ distribution, but it is very easy to understand and implement. Note that to speed up convergence, the initialization step relies on Bauer’s distribution.

13 Bauer’s distribution, Bn, is obtained through the method presented in [28]. Bauer’s aim was to design a direct method, with application to star catalogs. The points are actually placed on a spiral (Fig. 2.3b), as spirals are a natural structure for evenly distributing points over a sphere. Bauer’s construction is simpler than, e.g, Rakhmanov et al.’s [30], but seems to produce a distribution that is about as even [39].

Koay’s distribution, Kn, is obtained through the method presented in [31]. Koay’s aim was to design a direct method that would generate an antipodally symmetric dis- tribution, with application to diffusion Magnetic Resonance Imaging. He used latitude circles instead of a spiral (Fig. 2.3c), because spirals are inherently incompatible with antipodal symmetry.

The great circles distribution, Gn, is obtained through the method described in Section 3.1.3, with application to, e.g., image analysis. The aim is to provide a direct method that generates an antipodally symmetric distribution such that the number of great circles needed to contain all the points of the distribution is as small as possible.

Finally, Cn is the cubed sphere distribution. It was originally introduced by Sadourny in 1972 as a tool for weather simulation [40] and later gained popular- ity [41] [42] [43] [44]. The aim was to provide an alternative to the standard latitude- longitude grid in spherical geometry, free from singularities at the poles. Consider a cube inscribed in the sphere. A rectilinear grid is used to partition each face of the cube into rectangular regions; the grid is not uniform, as consecutive gridlines are not equidistant but equiangular with respect to the center of the cube. Now, consider the central projection whose center is the center of the cube. The cubed sphere distribu- tion is obtained by projecting every vertex of every rectangular region onto the sphere.

14 Although the application areas, the aims and the approaches are different, the great circles and the cubed sphere distributions happen to have similar characteristics and can be considered variants of each other. See Table 2.2, Fig. 2.3 and Section 3.2.2.

(a) (b) (c) (d)

Figure 2.3: (a) With Wn and Tn the points can be anywhere on the sphere. (b)

With Bn the points are on a spiral. (c) With Kn the points are on latitude circles.

(d) With Gn and Cn the points are on great circles

2.2.3 Evenness Measures

To determine if a distribution of points on a sphere is “even”, we must determine what even means. Many metrics can be found in literature [45] such as: Separation Distance, Mesh Norm, Mesh Ratio, and Energy. Here, the space is the three-dimensional Euclidean space; the origin is an arbi- trary point of the space; the sphere, S, is the set of points of the space that are all at distance 1 from the origin; a distribution is a tuple of points of the sphere; n is a positive integer; (pi)i∈1..n is an n-point distribution.

Energy

Assume each point of the distribution (pi)i∈1..n indicates the location of an elec-

15 Table 2.2: Some characteristics of the six distributions considered here

some characteristics distributions directly antipodally on great comments generated symmetric circles

Wn NO NO NO strives to minimize energy through effective algorithm

Tn NO NO NO strives to maximize evenness through simple algorithm

Bn YES NO NO -

Kn YES YES NO -

Gn YES YES YES strives to minimize number of great circles

Cn YES YES YES provides an alternative to latitude-longitude grid

16 Figure 2.4: Algorithm to compute the tailored distribution

17 tron. The electrostatic interaction energy occurring between each pair of electrons is given by Coulomb’s law. The energy of the distribution is the global electrostatic potential energy of the corresponding n- configuration:

X 1 (2.3) |p − p | 1≤i

Separation Distance

The separation distance of the distribution (pi)i∈1..n is the minimum distance between any two points of the distribution:

min1≤i

We may consider that the greater the separation distance, the more even the distribution. Finding an n-point distribution that maximizes the separation distance is solving the Tammes problem. Note that half the separation distance is the packing radius: n identical spherical caps centered at the points of the distribution do not overlap if their common radius is less than or equal to the packing radius.

Mesh Norm

The mesh norm of the distribution (pi)i∈1..n is the largest distance that a point of the sphere can be from the closest point in the distribution:

maxq∈S(min1≤i≤n|q − pi|) (2.5)

18 The mesh norm can be calculated using the Voronoi partition of the sphere in- duced by the distribution. Indeed, it is also the largest distance that a vertex of the Voronoi cell associated with a point of the distribution can be from that point. We may consider that the lower the mesh norm, the more even the distribution. Note that the mesh norm is also referred to as the covering radius: n identical spherical caps centered at the points of the distribution completely cover the sphere if their common radius is greater than or equal to the covering radius.

Mesh Ratio

The mesh ratio of the distribution (pi)i∈1..n is the result of the division of the mesh norm by the separation distance:

max (min |q − p |) q∈S 1≤i≤n i (2.6) min1≤i

19 Chapter 3

Direction Sets for Force Histogram Computation

in the case of 3D Vector Objects

In this chapter we introduce a new point distribution technique Section 3.1. We then compare the evenness using common metrics with various number of points for each technique in Section 3.2.

3.1 Variant

A new variant of the problem of evenly distributing an arbitrary number of points over a sphere is presented in Section 3.1.2. The motivation behind that variant is explained in Section 3.1.1, and a first direct solution is given in Section 3.1.3.

3.1.1 Motivation

In this section, E2 is the Euclidean plane and E3 is the Euclidean space of dimen- sion 3 (which is considered to include E2). A direction is a unit vector. The lower-case symbols i, s and d denote, respectively, an isometry, a subset and a direction of E2, while the upper-case symbols I, S and D denote, respectively, an isometry, a subset and a direction of E3. Consider a real function f such that:

f(i(s), i(d)) = f(s, d), (3.1)

for any isometry i, subset s and direction d of the plane. See Fig. 3.1 for an example of such a function.

20 Let us extend f to 3-D sets and directions. First, consider the real function fˆ such that:

fˆ(I(s),I(d)) = f(s, d), (3.2)

for any isometry I of E3 and for any subset s and direction d of E2. See Fig. 3.2. Next, let o be an arbitrary point of E3 (the origin); for any direction D of E3, let

⊥ D be a direction orthogonal to D; for any real number t, let Pt(D) be the plane perpendicular to D⊥ that passes through p, where p is the point defined by:

−→op = tD⊥. (3.3)

See Fig. 3.3. Finally, let F be the real function such that:

Z +∞ ˆ F (S,D) = f(S ∩ Pt(D),D)dt, (3.4) −∞ for any subset S and direction D of E3. Assume F does not depend on the origin o or on the way D⊥ is chosen. F is then an additive (integral) extension of f from 2-D sets and directions to 3-D sets and directions. This is a fairly common extension. For instance, if f(s, d) is the total length of the orthogonal projection of the plane figure s on a line perpendicular to d, then F (S,D) is the total area of the orthogonal projection of the solid figure S on a plane perpendicular to D. See Figs. 3.1-3.3.

Note that more than one subset of the plane may be considered by f. Replace,

2 e.g., (1) and (2) with (5) and (6), where s1 and s2 denote two subsets of E , and 3 replace (4) with (7), where S1 and S2 denote two subsets of E :

f(i(s1), i(s2), i(d)) = f(s1, s2, d) (3.5)

ˆ f(I(s1),I(s2),I(d)) = f(s1, s2, d) (3.6)

21 Z +∞ ˆ F (S1,S2,D) = f(S1 ∩ Pt(D),S2 ∩ Pt(D),D)dt (3.7) −∞

For instance, if the function d 7→ f(s1, s2, d) is the histogram of forces that represents the relative position of the 2-D objects s1 and s2, then the function D 7→ F (S1,S2,D) is the histogram of forces that represents the relative position of the 3-D objects S1 and S2. The histogram of forces [9, 10] is a relative position descriptor [5]: it carries quantitative information about the spatial arrangement of objects—which is a feature people continuously rely on to understand and communicate about space. Its appli- cations include human-robot interaction [46], geospatial information retrieval [47], scene matching [48], technical document analysis [49], satellite image analysis [50] and urban land use extraction [51], to mention a few.

Now, assume there is a program that can compute f(s, d) for any subset s and any direction d of E2. The extension F can then be implemented using (4) and some numerical integration technique. Consider a subset S of E3. Assume we are interested in the function D 7→ F (S,D). In practice, the value F (S,D) cannot be computed for all possible directions D. However, a representative sample of values can be collected by choosing a finite set of reference directions that are evenly distributed in the 3-D space; the more reference directions, the more complete the sample, but the longer the processing time. Likewise, only a finite number of slices S ∩ Pt(D) can be considered when computing a given value F (S,D); the more slices, the more accurate the result, but the longer the processing time. For efficiency purposes, it then makes sense to process coplanar reference directions simultaneously, since the same slices can be used for these directions; and it would be ideal if we could divide the reference directions into just a few groups of coplanar directions. Given that any direction in the 3-D space corresponds to a point on the unit sphere, here is how we can reformulate this: find a finite set of points that are evenly distributed over the sphere and that belong to a minimum number of great circles.

22 f(i(s),i(d)) f(s,d) s d i(d)

i(s)

Figure 3.1: Function f. In this example, f(s, d) is defined as the total length of the orthogonal projection of the plane figure s on a line perpendicular to d; for any isometry i, we have f(i(s), i(d)) = f(s, d)

^ f(I(s),I(d)) f(s,d) s d I(d) E2

I(s)

Figure 3.2: Defining fˆ from f. In this example, f is as in Fig. 3.1

23 F(S,D) S D⊥

^ f(S∩Pt(D),D)

D p

Pt (D)

o

Figure 3.3: Defining F from fˆ. In this example, fˆ is as in Fig. 3.2; the value F (S,D) is therefore the total area of the orthogonal projection of the solid figure S on a plane perpendicular to D

24 3.1.2 Formulation

Our aim is to find distributions of points over the sphere that meet the following criteria: (i) the distribution is as even as possible; (ii) it is antipodally symmetric; (iii) the number of great circles needed to contain all the points of the distribution is as small as possible. Our motivation behind (ii) and (iii) is to speed up the compu- tation of relative position descriptors (like the histogram of forces) in the case of 3-D objects; see [9] for (ii) and Section 3.1.1 for (iii). As far as we know, this criterion (iii) has not been considered in the literature.

Obviously, it is possible to find a set of great circles such that each point of the distribution lies on at least one of the circles. Each circle can actually be chosen so that at least four points lie on it: two arbitrary points and their antipodes. For example, no more than 25 great circles are needed for a 100-point distribution. But can we find a distribution such that fewer circles are needed, without sacrificing evenness?

3.1.3 Solution

We present here a first direct solution to the problem formulated in Section 3.1.2.

Let k be a positive integer. Assume Cx,1,Cx,2, ..., Cx,2k are 2k great circles such that each circle intersects the x-axis, the angle between any two consecutive circles

π is 2k , and the set of circles is invariant under reflection through the xz-plane. Like- wise, assume Cy,1,Cy,2, ..., Cy,2k are 2k great circles such that each circle intersects π the y-axis, the angle between any two consecutive circles is 2k , and the set of circles is invariant under reflection through the yz-plane. Now, consider a point p in the intersection of some Cx,i and Cy,j such that the angles between Cx,i and the xz-plane π 2 and between Cy,j and the yz-plane are less than 4 . There are 2k such points. They can be distributed over k great circles, with 2k points per circle (k points and their antipodes). See Fig. 3.4.

25 The process we have just described is repeated twice: once with circles cutting the y- and z-axes (replace each occurrence of x with y, of y with z, of z with x) and once with circles cutting the z- and x-axes (replace x with z, y with x, z with y). In the end, we get a total of 6k2 points. These points can be distributed over 3k great circles, with 2k points per circle. If k is odd then we can also distribute them over 3k − 1 circles: 1 circle is allocated 4k points and the other 3k − 2 cir- cles are allocated 2k points each. See Fig. 3.5. Table 3.1 summarizes these results for small values of k. Views of different point distributions can be found in Section 3.2.

y y

. z x z x

(a) (b)

Figure 3.4: Point selection (first stage) — In these parallel projections, each one of

the great circles Cx,1,Cy,1,Cx,2,Cy,2, ..., Cx,2k,Cy,2k is visible as a semi-ellipse, a line segment or the contour of the sphere. The circles intersect in many points, only some of which (the black dots and their antipodes) are kept for the distribution. (a) k=2; (b) k=3

26 y y

. z x z x

(a) (b)

Figure 3.5: Point selection (result) — In these parallel projections, each one of the

great circles Cx,1,Cy,1,Cz,1,Cx,2,Cy,2,Cz,2, ..., Cx,2k,Cy,2k,Cz,2k is visible as a semi-ellipse, a line segment or the contour of the sphere. The circles intersect in many points, only some of which (the black dots and the white dots as well as their antipodes) are kept. Black dots (resp. white dots) joined with a continuous line belong and are assigned to the same Cx,i circle (resp. Cy,j circle). (a) k=2; (b) k=3

27 Table 3.1: Points evenly distributed over the unit sphere and a minimum number of great circles

k 1 2 3 4 5 6 7 8 n 6 24 54 96 150 216 294 384 number of great circles 3 6 9 12 15 18 21 24 number of points per circle 2 4 6 8 10 12 14 16

k 9 10 11 12 13 14 15 16 n 486 600 726 864 1014 1176 1350 1536 number of great circles 27 30 33 36 39 42 45 48 number of points per circle 18 20 22 24 26 28 30 32

3.2 Comparative Study

The evenness of the distributions introduced in Section 3.1.3 is assessed in Section 3.2.1 — using measures that were presented in Section 2.2.3 — and compared to the evenness of other distributions — presented in Section 2.2.1. Additional comments are provided in Section 3.2.2.

3.2.1 Evenness Results

Wales’ distributions are available on the Cambridge Cluster Database [52] and Koay’s code is available online [53]. The algorithms for the other distributions were implemented in C and run on a Mac Mini with 3.0GHz Dual-Core Intel Core i7 and 16GB 1600MHz LPDDR3 SDRAM.

The energy, the separation distance and the mesh ratio were used as evenness measures. Overall, as shown in Figs. 3.6-3.8, the most even distribution is Wn. This is not surprising, since the aim of the authors was to generate a distribution with

28 the lowest possible energy. No other constraints were considered, and the authors used the most effective algorithm they could come up with to achieve their aim. The

next most even distribution is Tn. This is not surprising either, since the aim was similar. Again, no other constraints were considered, but while the algorithm gained

in simplicity, it lost in effectiveness. The next three distributions are Bn, Kn and

Gn, in that order, because more and more constraints were considered (Table 2.2).

Finally, the least even distribution is Cn. Note that the evenness results regarding

Wn, Bn and Cn are consistent with those reported by Hardin et al. [45], who also consider these distributions in their comparative study. For example, the product of √ n and the separation distance of Bn tends to a value greater than 3.13 when n tends

towards infinity, and the mesh ratio of Cn seems to quickly converge to 1.

Some exceptions apply to the general results above. When the mesh ratio is

used as the evenness measure, Tn is often more even than Wn. In other words, a distribution with the lowest possible energy is not necessarily a distribution with the

lowest possible mesh ratio. Moreover, when n is low, Kn may be less even than Gn

according to the mesh ratio, and when n is high, it may be as even as Bn according to the separation distance.

For a visual comparison of Tn, Bn, Kn and Gn, see Fig. 3.10. On close ex- amination, a spiral, latitude circles and great circles are discernible in (b), (c) and (d), respectively. When n=1536 and the evenness measure is the energy, the 9000 distributions indicated in Fig. 2.4 are computed in about 3 minutes — not including the time needed to measure their evenness — and the 9000th is the most even of

them, i.e., it is the tailored distribution T1536. On the other hand, B1536 is computed in about 500 microseconds and G1536 in about 1500 microseconds. More on Gn vs.

Cn can be found in Section 3.2.2. For a more detailed view, Figure 3.9 shows the processing times of Tn, Gn, and Bn for various values of n.

29 0.16% 0.14% 0.12%

0.1% Cn G 0.08% n 0.06%

energydeviation 0.04% 0.02% Kn Bn 0% Tn Wn 150 294 216 384 486 600 726 864 1014 1176 1350 1536 number of points (n)

Figure 3.6: Energy as the evenness measure. The energy deviation of a distribution

is, e.g., 0.1% if its energy is 0.1% more than that of Wn. The energy deviation of

Wn is, therefore, 0%, for all n. Wales’ distribution is always the most even distribution, while the cubed sphere distribution is always the least even

30 3.6

n 3.5 Wn * 3.4

3.3 Tn 3.2 Bn 3.1 3 Kn 2.9 Gn

separationdistance√ 2.8 C 2.7 n

150 294 216 384 486 600 726 864 1014 1176 1350 1536 number of points (n)

Figure 3.7: Separation distance as the evenness measure. Wales’ distribution is always the most even distribution, while the cubed sphere distribution is usually the least even

31 1 Cn

0.95 Gn 0.9

0.85 Kn

0.8 Bn meshratio 0.75 Tn W 0.7 n 0.65

150 294 216 384 486 600 726 864 1014 1176 1350 1536 number of points (n)

Figure 3.8: Mesh ratio as the evenness measure. Wales’ distribution is often the most even distribution, while the cubed sphere distribution is always the least even

32 Plot of Computation Time for Distributions

● ● ● ● ● ● 32.000 ● ● ● Seconds)

● Distribution 2 ● g

o ● Tn 9000 L ● 2.000 Tn 5000 Gn Bn

0.125 Time to Compute (

400 800 1200 1600 Number of Points

Figure 3.9: The time required to compute the Tn, Gn, and Bn distributions for th th various values of n. Tn is shown twice, at the 5000 and 9000 iteration. We see

that Tn takes a very large amount of time to compute. While Gn, and Bn are

require similarly small amount of time, with Bn often slightly faster.

33 3.2.2 More on Gn vs. Cn

As mentioned in Section 2.2.1, the great circles and the cubed sphere distribu- tions can be considered variants of each other. We have shown in Section 3.2.1 that

Gn outperforms Cn in terms of evenness. In this section, we take a closer look at their similarities and differences.

2 2 Gn is only defined for n = 6k , where k is a positive integer, and these 6k points

can be distributed over 3k great circles (Section 3.1.3). Likewise, Cn is only defined for n = 6k2 + 2 — see, e.g., [45] — and these 6k2 + 2 points can be distributed over 3k − 1 great circles. When k is odd, the six poles belong to Gn, but none be- longs to Cn, where a pole is defined as a point whose coordinates x, y and z satisfy x2 + y2 + z2 = 1 and max(|x|, |y|, |z|) = 1. When k is even, the six poles belong to

Cn, but none belongs to Gn.

For a visual comparison of Gn and Cn, see Figs. 3.11 and 3.12. Consider, e.g.,

G150 and C152. The “north” pole belongs to G150 (upper view, Fig. 3.11a) but does not belong to C152 (upper view, Fig. 3.12a). Also note that some points of C152 are arranged in the form of a ‘Y’ (lower view, Fig. 3.12a) but there is no such arrange- ment in G150 (lower view, Fig. 3.11a).

As mentioned in Section 1.2 and developed in Section 3.1, the motivation behind

Gn is to speed up the computation of relative position descriptors in the case of 3-D objects. Given the importance of the cardinal directions right, left, above, below, front and behind when considering relative positions, one may want to revise the formula- tion in Section 3.1.2 and add one more constraint: (iv) the distribution includes the six poles. In that case, one may want to use a hybrid of Gn and Cn, i.e., G6k2 for all odd positive integers k and C6k2+2 for all even positive integers k.

34 (a) (b) (c) (d)

Figure 3.10: Three views of (a) the distribution T486 tailored to energy minimization, (b) Bauer’s distribution B486, (c) Koay’s distribution K486, and (d)

the great circles distribution G486

35 (a) (b) (c) (d)

Figure 3.11: Two views of the (a) 150-point, (b) 384-point, (c) 726-point, and (d) 1176-point great circles distributions

(a) (b) (c) (d)

Figure 3.12: Two views of the (a) 152-point, (b) 386-point, (c) 728-point and (d) 1178-point cubed sphere distributions

36 3.3 Conclusion

In this chapter, we have introduced a new variant of the problem of evenly distributing an arbitrary number of points over a sphere: the distribution must be as even as possible, it must be antipodally symmetric, and the number of great circles needed to contain all the points of the distribution must be as small as possible. We have proposed a solution to that variant — the great circles distribution — and we have compared that solution with five other distributions. The more constraints on the distribution, the less even it is. We have illustrated and quantified this using three evenness measures. Although the application areas, the aims and the approaches are different, the great circles and the cubed sphere distributions happen to have similar characteristics. The cubed sphere distribution uses one great circle less, but it is not as even as the great circles distribution, especially when the evenness measure is the separation distance or the mesh ratio. Applications of this work are envisioned in areas where 3-D objects must be handled. Our specific motivation was to speed up the computation of relative position descriptors in the case of polyhedral objects. Using the great circles distribution [16] instead of other distributions [1] allowed us to divide processing times by about p3n/2, where n denotes the number of points in the distribution. For example, with 100 points or so, the processing times are about 10 times shorter; with 400 points, they are 20 times shorter; with 1500 points, they are 50 times shorter [16]. While the great circles distribution is a solution to the variant above, it might not be the best solution. In future work, we will strive to find a more even distribution, or a distribution such that the n points are distributed over fewer great circles, or a distribution defined for all positive integers n (the great circles distribution is only defined for positive integers of the form n = 6k2), or — and this is a much bigger challenge — a distribution that satisfies all of the above.

37 Acknowledgments and Contributions

This research project was originally assigned an Undergraduate Research Assis- tant: Mark Smith. When it was reassigned to me, a variety of existing distribution techniques, three existing evenness measures, as well as the ability to draw the dis- tributions to images were implemented. However, much work was still needed. Some of the distribution techniques had been chosen inappropriately or modified

incorrectly, and additional distributions were required. For example, when testing Tn it soon became clear that the algorithm was not behaving as predicted. We expected that with each iteration of the algorithm the evenness would improve. However, when the evenness was plotted over time, this was not true. This resulted in the energy metric being implemented, and a realization that the Tn implementation that was provided had been incorrectly modified to force antipodal symmetry. As a result only one of the original distributions provided by Mark Smith was used in this work.

38 Chapter 4

PHI-Descriptor Computation in the case of 2D

Vector Objects

This Chapter will discuss the design (Section 4.1), implementation (Section 4.2), and testing (Section 4.3) of the first φ-descriptor algorithm for vector objects intro- duced in this thesis. The results are discussed in Section 4.4, the current limitations of the implementation are described in 4.4.1. Finally the conclusion, acknowledgments and contributions are in Sections 4.5.

4.1 Algorithm

The φ-descriptor looks for regions that belong to specific groups of elementary spatial relations, Phi Groups. The area and heights of these regions are summed to form the descriptor in one direction. This process is repeated in k directions to form the φ-descriptor. The goal of this new algorithm is to calculate the φ-descriptor for a pair of vector objects. The broad strokes of this algorithm are shown in Algorithm 1, to summarize the algorithm we 1) find vertices where the spatial relations change (Points of Interest) 2) divide the objects into subregions at each of these points such that each region is associated with a spatial relation 3) calculate and store the size of the regions 4) rotate the image and repeat steps 1-3 for each direction 5) finally we form the φ-descriptor from the calculated sizes. To divide the objects into subregions, we cast a horizontal “ray” passing through the Points of Interest (PoI), Section 4.1.1, and determine each location where the ray

39 intersects with the objects, Section 4.1.2. We then use a modified Point in Polygon Test , Section 4.1.3, to determine what object(s) these ray intersections lie on. Edges are added between each PoI and the ray intersections closest to them, Section 4.1.4. Phi Groups are assigned to specific vertices and ray intersections, Section 4.1.4. After these steps are performed for each PoI, we create one or more Phi Regions above each PoI, Section 4.1.5.

Algorithm 1 Vector φ-descriptor 1: for all θ ∈ direction set do

2: Find PoI

3: for all PoI do {Create Rays}

4: Find endpoints

5: Point in Polygon Test

6: Determine PoI Phi Groups for direction θ and −θ

7: Add edges between endpoints

8: end for

9: Find Phi Regions at each PoI

10: Calculate size of Phi Regions

11: Save Phi Region sizes to descriptor

12: Remove edges and points created with Rays.

13: Rotate objects by θ

14: end for

4.1.1 Points of Interest

To find Phi Regions we must look at what would make one portion of the objects change to a different spatial relationship. The points in which these changes occur we will call Points of Interest (PoI), see Figure 4.1, and are confined to the region of interaction, the vertical space which both objects share. The top and bottom points

40 of the region of interaction are both PoI, as well as any local extrema within that region, and any point where the boundaries of the objects intersect.

Region of Interaction

The Region of Interaction is defined by two vertices, the top and bottom. The top is the lower of the highest vertex of each object. The bottom is highest of the lowest vertex of each object.

Extrema

The extrema are vertices with both neighbours either above (minima), or below (maxima) the vertex. We can consider that a pair of vertices can form an extrema pair if both vertices share a Yvalue, they are neighbours of each other, and their remaining two neighbours are both either above (minima), or below (maxima) the pair.

Intersections

The intersections are points where an edge from one object intersects an edge from the other. These are determined during a preprocessing phase outside the scope of this thesis. The other types of PoI may change after each rotation (ie a minima may no longer be a minima after a rotation), the intersections remain a PoI throughout the algorithm. For this reason the Intersection test need only be conducted once as a pre-processing step.

41 T I2

I1

Max1 Max2 Min1

I3 I4

Min2

B

Figure 4.1: This image shows the Region of Interaction, as a dotted box. The PoI are shown: Top (black square), Bottom (grey square), Intersections (white circle with black border), Local Minima (black circle), and Local Maxima (grey circle).

4.1.2 Find Ray Intersections

For each of these PoIs we need to divide the objects into Phi Regions, and assign a Phi Group to the region. To accomplish this, we need to find where the edges of the objects intersect with a ray in direction θ that passes through the PoI, Section 4.1.2. We will call these intersections the endpoints of the Ray. Once we have found the endpoints we need to sort them, and use a Point in Polygon Test (Section 4.1.3) to determine whether the endpoints lie on object A, B, both, or neither; this is the point’s source. Using the sources we look on the Phi Group tables (Figure 2.2) to determine and assign the correct Phi Groups for directions θ and −θ to the point. When an

42 endpoint lies exactly on a vertex already in the object, we check if it is a PoI; in the case that it is a PoI we follow requirements in Sections 4.1.4 and 4.1.4. Certain endpoints are stored to form the Ray, depending on the PoI (intersection, top, bottom, etc.), we will look at this in detail in Section 4.1.4. The points on the Ray, and the edges connecting them are added to the data structures storing all points, Section 4.2.2. These newly added points and edges form the perimeters of the Phi Regions.

43 A1 B10 A1 A11 B9 B8 A7 B5

B5 B14 B12 A11 A8 B6

(a) Local Minima A1 and B5 along with the (b) All ray intersections located. rays passing through.

B3 A4 I2 B

A3

I1 B0

A0 B7 B10 A1 A11 B10 A1 A11 A6

I3 I4

A8 B5 A8 B5

A9

B9

(c) The edges and endpoints formed by the ray (d) The new edges and endpoints added to the are determined. original objects.

Figure 4.2: An example creating two Rays from Local Minima.

44 An example of creating a Ray can be seen in Figure 4.2 where the endpoints formed by two local minima have been inserted. The figure shows new edges coming from local minima, these edges split the objects into multiple smaller regions (above B10, A1, A11, and B5 in Figure 4.2 (d)). The local minima at B5 has formed a single region where none had existed before, this new region will have the spatial relationship trails associated with it. An example, with all Rays created, can be seen in Figure 4.6; this example will help to understand the special needs required in creating the different types of Rays in Section 4.1.4. Before creating a ray from a PoI first test if the current PoI has already been assigned a Phi Group. If the PoI has a Phi Group then another PoI shares a Yvalue and thus the current PoI has been processed. This test prevents a ray from being processed redundantly.

4.1.3 Point in Polygon Test

This test is used to determine what object(s) a point lies on (source). This infor- mation is then used to determine what Phi Group that point belongs to. This Point in Polygon test is widely used to determine if a point lies inside of the perimeter of a polygon. This “standard” test is described below, the modified version is specialized for use in the Vector Phi algorithm.

Standard

In the standard Point in Polygon test a “ray” is passed through the point being tested. All intersections with the ray and the edges of the polygon are determined. The intersections on one side of the test point are counted. If the count is even the test point is not in the polygon, if the count is odd the point is in the polygon.

45 Modified

The standard test results in a boolean: either the point is in the polygon, or not. The modified version tests against two objects, with 4 possible outcomes. The test point is in: object A, B, both A and B, or neither A nor B. By determining the source(s) of all the ray intersections we can determine the Phi Group of each point in the core. An example of this can be seen in Figure 4.3. While creating the Core, we passed a ray and found all intersections (endpoints), it is each of these endpoints we wish to test. Seeing as the ray intersections have been found we need not repeat this step. We will instead start by sorting the endpoints left to right. Starting on the left point we count as with the standard test, if the point came from object A we increment the A counter, if the point came from object B we increment the B counter. Special care is required for any extrema or intersection PoI encountered, they must be added twice. After each point we check if the counters are odd or even. If one is odd, the point lies on that object. If both are odd the point lies on both objects. If neither are odd, then the point is in neither object. For intersection PoIs we must add a copy of the point from object A and from object B. The order they are inserted is important, we look at the neighbours of the intersection point to determine this order. If the top-left neighbour is from object A, we add a copy from object A first; if the top-left neighbour is from object B, we add a copy from object B first. The second copy is from the other object.

4.1.4 Create Rays

Once we have found and sorted the ray intersections, we mark some as endpoints which form the Ray. The various types of PoI have individual requirements, each will be discussed in this section. The goal is to add edges to adjacent points in the rays to form the Phi Regions above it.

46 B10 A1 A11 B9 B8 A7 B5

Figure 4.3: The start and finish of the Point in Polygon test. On the left the ray and its intersections are shown. On the right, the source of those ray intersections are shown. Black circles indicate the ray intersection lies on object 1, grey indicates it lies on object 2. White circles with a black border indicate that the point lies on both objects.

47 Region of Interaction

The Ray along the bottom of the region of interaction spans the entire width of both the objects. For this Ray each ray intersections is an endpoint, and added to the data structure of the objects. Edges are added to ensure a connection between all adjacent endpoints. There are no regions above the Top point of the Region of Interaction, therefore there are no endpoints kept in the Ray. However all endpoints are still added to the data structure, and edges are formed to connect adjacent endpoints. To optimize further the Phi Groups and the sources of the endpoints do not need to be determined. These top and bottom rays can be seen in Figure 4.6, they are numbered A6 and A15 respectively.

Local Extrema

For a Ray created from a local maximum, only the PoI is kept in the Ray. This is because only one Phi Region is formed above the Ray. For a Ray created from a local minimum the PoI and the closest neighbour on the left and right (if they exist) are endpoints kept in the ray. In both cases the ray intersections to the left and right are added to the objects, as well as edges to the PoI. These PoI and rays can be seen in Figure 4.6, the maxima are numbered A0 and B11 and the minima A1 and B9.

Intersections

For a Ray created from an intersection, the PoI, and the closest neighbour on the left and right (if they exist) are endpoints kept in the ray. In both cases the ray intersections to the left and right are added to the objects, as well as edges to the PoI. It is treated very similar to a minima. These intersection rays can be seen in Figure 4.6, they are numbered I1 ,I2, I3, and I4.

48 Determine Phi Group

When determining the Phi Group we check directions θ and −θ. To determine the Phi Group of a given PoI we look at the the source of the PoI, and the source of the points adjacent to it on the Ray. In the minima PoI in Figure 4.3, we can see its source is both objects, and the points to the left and right are from object B. Therefore when referencing Table 2.2 we are looking for the relation B, both, B, which is part of the overlaps Phi Group. When determining the Phi Group we check directions θ and −θ, the relation mentioned above is symmetrical which means overlaps is assigned to the PoI in both directions. We would similarly need to determine the Phi Group of the endpoints to the left and right as it is a minima. In direction θ the relation of the endpoint to the left is nothing, B, both, which does not correspond to any Phi Group, however in direction −θ the relation both, B, nothing corresponds to the uncovers Phi Group.

Multiple Vertices on a Single Ray

When a PoI does not share a Yvalue with any other PoI the creation of the ray is as described above; however it can be complicated when multiple PoI share a Yvalue, or when a vertex from one of the objects exactly intersects the ray. For example Figure 4.4 shows a ray with a minima directly beside a minima; in this case one of these PoI must create fewer regions. Figure 4.5 shows a horizontal edge adjacent to a PoI, in this case the point adjacent to the PoI does not accurately show the source to the right of the region, so we must look two points over to determine the Phi Group. If an intersection PoI lies on a horizontal line, the edges added do not originate from the PoI itself but rather from the neighbors along the horizontal edge. Care must be made to consider combinations of all types of PoI adjacent to one another. The extrema PoI is any vertex where both neighbours lie either above or below it. We can consider that a pair of vertices can form an extrema pair if both vertices share a Yvalue and they are neighbours of each other, and their remaining two neighbours

49 Figure 4.4: An example with many PoI sharing Yvalues. The image contains extrema adjacent to one another, as well as with multiple edges between two extrema that share a Yvalue. Additionally there are many intersection points that share a Yvalue.

are both either above or below the pair. As mentioned in Section ??, two copies of extrema are added to the ray; in the case of an extrema pair we simply add the pair of points. An example of an extrema pair can be seen in Figure 4.4. We must take care to consider intersection(s) with the edge between the two vertices forming an extrema pair.

4.1.5 Create Phi Regions

Once all rays have been determined, and the new points and edges added to the objects (see Figure 4.6) we determine the Phi Regions. The process of finding the Phi Regions is shown in Algorithm 2. Starting at the rightmost endpoint in each ray (already sorted from Section 4.1.3), traverse the neighbours in a counter-clockwise cycle above the endpoint. We measure the angle between edges to ensure we are proceeding in a counter-clockwise direction. This cycle is a list of points defining

50 Figure 4.5: An example with a PoI next to a horizontal edge. Determining the Phi Group for the region above the maxima is made complicated as the endpoint to the right of the PoI does not indicate the source to the right of the Phi Region.

51 B4 A6 B3 B5 A5 I2 B6B

A4

I1 A8 Void B0 Argument Referent A2 A0 A9 Trails A18 B11 A10 Overlaps B18 A1 A17 A11 Covers Uncovers Follows B12 I3 B8 B17 I4 A13 Leads Starts A14 B9

B16 B14 A15

B15

Figure 4.6: On the left the objects are shown after all Rays have been determined and the new points and edges added (edges shown as dashed lines. On the right the the Phi Regions are shown. Note that the endpoints in the Rays create Phi Regions above them. The Phi Region is not drawn if there is no corresponding Phi Group. a polygon that we refer to as the Phi Region. The first element in each list is an endpoint that has already been assigned a Phi Group. After each counter-clockwise point is determined, the edge connecting the previ- ous point to the next point is removed (Algorithm 2 Line 9). This ensures that the same region can not be found twice, and reduces the total number of edges to speed up subsequent phi region detection. The first point added to the list is the endpoint that the region originated from (Algorithm 2 Line 3). The second point (Algorithm 2 Line 4) is a neighbour of the first. If there exists a neighbour exactly to the right of the first point it is chosen as the second point. Elsewise the neighbour with the smallest angle from the x-axis is chosen and added to the back of the list. Once the first two points have been determined; we look through all neighbours

52 Algorithm 2 Find Phi Regions 1: for all Rays do {In any order}

2: for all Endpoints on Ray from right to left do {Already sorted during Point in Polygon Test}

3: Create a list of points with the endpoint as the first element.

4: Set next to the rightmost neighbour of the endpoint that is not below it.

5: Remove edge from endpoint to next.

6: while next != endpoint do

7: Add next to list.

8: Set next to the neighbour of next that is most counter-clockwise.

9: Remove edge from previous to next.

10: end while

11: Store this list of points as a Phi Region. {The first point will have a Phi Group assigned to it already.}

12: end for

13: end for

53 of the point in the back of list for the most counter-clockwise (Algorithm 2 Line 8). The most clockwise neighbour has the smallest angle between a line formed by the last two points in the list, and the neighbour. This point is then added to the back of the list. We repeat this until the most counter-clockwise is the starting point.

Finding Size of Region

The φ-descriptor requires the size of each Phi Region. The area of the Phi Region is used for the size, as well as either the height or length of the Phi Region. Algorithm 3 shows the algorithm used to find the area of a polygon [54] (Phi Region). To calculate the height of the phi region take the difference of the maximum and minimum Yvalues of all points in the Phi Region. The length is calculated as the

area height for consistency, as it was calculated this way in the φ-descriptor for raster objects.

Algorithm 3 Find Phi Region Area 1: numPoints = number of points in polygon[].

2: area = 0

3: j = numPoints -1

4: for i = 0 to i = numPoints do

5: area+ = (polygon[j].x + polygon[i].x) ∗ (polygon[j].y − polygon[i].y)

6: j = i

7: end for

4.1.6 Rotation

The φ-descriptor requires the size of regions in multiple directions. The number of directions k must be an even number greater than zero ie k = 2j where j ∈ Z, j ≥ 1. This is because directions are processed in antipodal pairs, when a Phi Group in direction θ is determined the Phi Group for direction −θ is easily determined as well.

54 The rotations are completed by transforming all points in the two objects as shown in Algorithm 4. To rotate the objects we need to find a centroid to rotate around, this centroid is calculated once at the start of the algorithm and used for each rotation. The centroid point is the average of all vertices from both objects. In addition to rotating we remove all remaining points and edges from the cre- ation of the Rays. We want to return the objects to their original state, ie only the initial vertices, object intersections, and edges between these vertices and intersec- tions. If this step is performed before the rotations the number of rotation operations required is reduced.

Algorithm 4 Rotate Object 1: centroid = (mean(Xvalues), mean(Y values)

2: for all Point p in object do

3: ∆x = p.x − centroid.x

4: ∆y = p.y − centroid.y

5: p.x = centroid.x + ∆x ∗ cosθ − ∆y ∗ sinθ

6: p.y = centroid.y + ∆x ∗ sinθ + ∆y ∗ cosθ

7: end for

4.1.7 Build Descriptor

After the sizes of all Phi Regions are determined for a direction, the results are combined to form a pair of columns in the descriptor. We look at each Phi Region, and add the appropriate sizes to the the θ and −θ columns at the row associated with the Phi Groups of the region.

4.2 Implementation

The details of the implementation of the new algorithm are described in this section. The core of the algorithm was written in c++, with tests being run using a

55 combination of python and bash. Prior to implementation a pseudocode algorithm was created and walked through with many sample polygons on a whiteboard. Once satisfied with the pseudocode it was presented to peers before implementation begun. The first version of the implementation used an array as a data structure to store the objects, it was apparent that this was inefficient and the implementation was modified to improve efficiency, see Section 4.2.2. As mentioned in Section 4.1.4 having multiple vertices sharing a Yvalue increases the complexity of the algorithm. For this reason it was determined that a limitation on the current implementation was acceptable, that the polygons not contain points sharing Yvalues. As progress continued it became apparent that this was too substantial of a limitation and work began to allow shared Yvalues. The final step in implementation before results could be determined was to rotate the polygons and loop over multiple directions.

4.2.1 Input and Output

The input to the program is two objects, the number of directions to compute the descriptor, and the desired location/name of the output descriptor. The objects are input as plain text files formatted such that each line contains the x and y coordinates of a vertex. The vertices can be floating point pairs (ex. 6.24 2.15) or integer pairs (ex. 100 250). The primary output is the descriptor, as described in Section 2.1.3, saved in a .CSV file. For testing purposes the program also output an SVG image which will be discussed in Section 4.3, for this reason the location/name of this image is also required input during testing.

4.2.2 Data Structures

The objects are stored in separate Doubly Linked Lists (DLLs) of points. The vertex data are stored in nodes, each node also contains two pointers to the closest clockwise, and counter-clockwise neighbours of the polygon. These pointers repre-

56 B3 B4 A4 A6 B3 B5 I2 B A5 I2 B6B

A3 A4

I1 I1 A8 B0 B0

A0 A2 A0 A9 B7 A18 B11 A10 A1 A6 B18 A1 A17 A11

I3 B12 I3 B8 I4 B17 I4 A13

B5 A14 B9

A8 B16 B14 A15

B9 B15

Figure 4.7: Object A is defined by the black dots (labeled A1, A2, ...). Object B is defined by the grey dots (labeled B1, B2, ...). Dots with a white center and black edges (labeled I1, I2, ...) belong to both objects. On the left the solid black lines indicate the edges of the DLL before and rays are determined. On the right the dashed grey lines indicate the neighbours of each point after all rays are determined. sent the edges on the perimeter of the objects, as shown on the left in Figure 4.7. Throughout the algorithm many points will be added/removed to these DLLs, so having fast insertion/deletion time is important. Section 4.1.4 details the points in which the edges of the objects intersect (vertices number I1, I2, I3, and I4 in Figure 4.7); those intersection points are added to the DLL in addition to the points defin- ing the objects. These intersection points are stored in a special type of node, with pointers to the neighbours from each object. Additionally each point stores a list of neighbours, this is necessary as in Section 4.1.4 more edges are added (in addition to the edges forming the perimeter of the objects). These neighbours form the edges in a directed graph (shown on the right Figure 4.7). Each point will have an edge to its neighbour, and that neighbour will

57 similarly have an edge back to it (for each edge Pn → Pm there is an edge Pm → Pn).

4.2.3 Visual Output

Visual output was implemented very early in development and used throughout. These images were used for quick testing, and to ensure that any changes had the desired effect. SVG (Scalable Vector Graphics) images were chosen, as an SVG can be created with plain text by defining polygons, lines, circles etc. To further aid in this a simple SVG library was created specifically for this this implementation. With this library each stage of the program could be drawn, for example after processing a Ray the state could be drawn with the objects, all points, and all edges. Similarly when finding Phi Regions each region could be drawn, with each Phi Region drawn with a color assigned to the Phi Group associated (Figure 4.6), it was then possible to visually check that each region was correct.

4.2.4 Testing During Implementation

Testing was completed at all stages of the implementation process. Errors would be thrown in known situations, such as if a point contained itself as a neighbour, a region had no Phi Group assigned in direction θ and −θ, etc. However the majority of the testing was manual, using visual output (Section 4.2.3). In cases where there was an error thrown, or the comparison results showed problems, the implementation was slowed to progress only on user input, producing a new image after each Ray or Phi Region.

4.3 Experiments

Once the implementation was at a point where it passed the manual and visual tests, an automated testing plan was enacted. The testing plan can be broken into five steps:

58 1. Generate random vector object pairs (Section 4.3.1). 2. Calculate φ-descriptor of vector object pairs (Section 4.1). 3. Convert vector objects to raster objects (Section 4.3.2). 4. Calculate φ-descriptor of raster object pairs. 5. Compare descriptors (Section 2.1.4). This automated test plan allowed for a large number of tests to be run, and quantitative results obtained. These results are discussed in Section 4.4.

4.3.1 Test Data

Two types of test data were used, objects that were created by hand to test specific scenarios, and randomly generated concave polygons to test large quantities of objects quickly. The manually created objects focussed on objects with shared Yvalues, as described in Section 4.1.4. Figure 4.8 shows an example of one such manually created object, and why they were important to test. Additionally objects that partially contain themselves, such as a spiral, are not possible with the poly- gon generator used. So additional manual objects were created to test particularly complicated polygons. To generate polygons [56], a number of random directions is selected, then a point is placed at a random distance in each direction, maintaining a clockwise progression. The algorithm contains some variables to have some control over the output, the number of directions, center of the polygon, “average” distance from the center for the points, the “spikiness” determines how much variance there is from the average distance, and “irregularity” controls how even the direction set is. By reducing the average distance of the points, and rounding the coordinates to integer values, it was possible to increase the number of shared Yvalues as well. However this was not perfect, and occasionally provided invalid polygons (ex. an object with edges that intersect). For this reason each was visually inspected. Objects created with both integer and floating point values were used for testing. Two examples of randomly

59 Figure 4.8: An example of an object pair created manually. The lighter shaded object obtained from [55]. This object was selected to test extrema pairs, having multiple points on the Top and Bottom rays, and more concave regions. generated object pairs are shown in Figure 4.9.

4.3.2 Convert to Raster Objects

We expect that similar object pairs should produce similar φ-descriptors regard- less of the type of objects (raster or vector). For this reason we wish to create the same object pairs in both raster and vector forms. We can then calculate the φ-descriptor of both to test if the similar objects produce similar φ-descriptors. A completed implementation to calculate the φ-descriptor using raster objects was provided for testing purposes. This implementation requires the objects to be coloured within a specific range of grey, and a specific file format. We use the SVG library from Section 4.2.3 to draw the objects with these color requirements. We take the SVG image as output for further processing. We next need to convert to a raster image. This was done using a free image library librsvg which contains a tool called rsvg-convert that can convert an SVG file to a png file. From here the

60 Figure 4.9: Two example object pairs created with the polygon generating algorithm.

61 Figure 4.10: The same image rasterized with crisp edges on the left, and with interpolated values on the right.

Python library Pillow was used to convert to the .PBM file format required by the provided program for raster images. The raster objects are required to have specific colors for the φ-descriptor algo- rithm. This requirement is met by drawing the objects in the appropriate colors, and disabling any interpolation techniques used in the rasterization. As shown in Figure 4.10 the default rasterizing algorithms “smooth” the edges between the objects, by interpolating color values along the edges. By disabling this interpolation the result- ing images have crisp edges that meet the requirements of the φ-descriptor algorithm for raster images. During this conversion the resolution of the raster image must be decided; in Section 4.4 the impact of the resolution choice in the raster φ-descriptor will be explored. The reason this has an impact is that the size of the regions will change as the number of pixels changes. This variability is reduced by “normalizing” the descriptors using the size of the Region of Interaction mentioned in Section 2.1.3.

62 For each direction, each area in the descriptor is divided by the area of the Region of Interaction, and each height is divided by the height of the Region of Interaction. The result is that the normalized descriptor contains percentages, rather than actual size data; for example “trails area in direction θ accounts for 2.1% of the Region of Interaction area”. When comparing the descriptors we are asking, does this region account for the same percentage in both descriptors?

4.4 Results

Figures 4.11 and 4.12 show the MinMax and SubAdd similarity results. Three hundred object pairs are tested, and converted to various raster image resolutions. The similarities tend to improve as the resolution of the raster objects increases. With an image width over 300 pixels the average MinMax similarity is over 0.9. While the average SubAdd similarity is is very high for all resolutions above 100 pixels wide. The graphs of the results show some outliers for pairs of descriptors that are particularly dissimilar. These results are from images that have very small regions, as shown in Figures 4.13 and 4.14. When rasterizing Phi Regions that are very thin, portions of the objects may fit between rows or columns of pixels. The resulting raster image may not show any pixels for these regions at all, see image 4.13. When objects have edges that are very close, the raster image may have pixels from the two objects directly adjacent; while the vector image shows the objects to overlap, or have a gap, as in Figure 4.14 . It is also important to note that we are not comparing the original descriptors, but rather a normalized descriptor. To normalize we divided the sum of the sizes for each Phi Group by the size of the region of interaction. If we look at Figure 4.14 it is apparent that the region of interaction will change dependent on what pixels are detected for each object. The results of both descriptors are correct for their input images, however the descriptors are different. While these examples show poor similarity, this does not indicate that either

63 algorithm is producing incorrect results. Both algorithms are giving the correct results for the images provided. The vector images provide a greater amount of information, so the resulting descriptors are dissimilar.

Plot of MinMax Similarity by Image Resolution

1.0 ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● 0.8 ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● Function ● ● ● ● ● ●

● Height ● ● 0.6 ● ● ● ● ● ●

● ● Area ● ● MinMax Similarity ● 0.4

● 0.2 100 300 500 700 900 1100 1300 1500 1700 1900 Image Width (Pixels)

Figure 4.11: Results of the MinMax similarity tests over various resolutions. 300 object pairs were tested at each resolution. As the resolution of the image increases the similarity improves.

64 Plot of SubAdd Similarity by Image Resolution

● ● 1.0 ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● 0.8 ● ● ● ●

● ● ● ● ● ● Function ● ● ●

● ● ● ● Height Area 0.6 ● SubAdd Similarity

● 0.4 ●

100 300 500 700 900 1100 1300 1500 1700 1900 Image Width (Pixels)

Figure 4.12: Results of the SubAdd similarity tests over various resolutions. 300 object pairs were tested at each resolution. As the resolution of the image increases the similarity improves.

65 Figure 4.13: These are two images of object pair test 73. This received low similarity scores. The image on the left has a width of 100 pixels, and the right 1,100. On the left many pixels show gaps in the object, as the section was too thin to be detected by the rasterizing algorithm.

66 Figure 4.14: These are two images of object pair 43 which received low similarity scores. The image on the left has a width of 100 pixels, and the right 1,100. There are multiple locations in the image on the left, where a pixel from object A is directly adjacent to a pixel from object B; Follows or Leads Phi Group. While this never occurs in the vector image, there is either an overlap or a space between the objects; Overlaps or Trails Phi Group.

When analysing the time required to calculate the φ-descriptor we must consider the number of vertices in the vector object. Figure 4.15 shows the processing time for 200 randomly generated object pairs, with random numbers of vertices (the total number of vertices of the pairs ranges from 12 − 181). We can see that the number of vertices has a large impact on the processing time, Figure 4.16 shows the object pair that required the most processing time, and had the most vertices. Figure 4.17 compares the processing time of these same 200 vector object pairs, to their raster counterparts, we examine the raster objects at 100, 500, 1100, and 1900 pixels in

67 width. We see the computation time for the φ-descriptor of raster objects is very consistent for a given object size; and as expected the more pixels in the raster object, the more processing time is required. When the raster objects are between 500 and 1100 pixels in width, and the vector object pair has less than 100 vertices, the φ-descriptors are often processed in roughly the same time range.

Plot of Vector Object Processing Time by Object Size

2.0 ● ●

● 1.5 ● ● ● ● ●● ● ●● ● 1.0 ●

● ● ●● ● ● ● ● ●● ● ●● ● 0.5 ● ● ● ● ● ● ● ● ● ●● ● ●●● ● Time to Compute (Seconds) ● ●●● ●●● ●● ● ●● ●● ●● ●●●● ● ●● ●●●●● ●●● ●●●●●●●●●● ● ●●●●●●●●●● ●● ●●●●● ● ●●● ●● ● ●● ●●●●●● ●● ●●●● ●● ● ● ●●●●●●● ● ● ●●●●●●●● ● ● ● ● ● ●●●●● ● 0.0 ● ● ● ● 50 100 150 Object Size (Number of Vertices)

Figure 4.15: The processing times of 200 vector object pairs. The number of vertices refers to the sum of number of vertices of both objects in each pair. It is clear that a larger number of vertices increases the processing time of the φ-descriptor computation for vector objects.

68 Figure 4.16: This is the vector object pair that required the most processing time. There are a total of 181 vertices between the two objects.

69 Plot of Object Processing Time Size

2.0 ● ●

● 1.5 ● ObjecType ● ● ● Vector ●●● ● ● ● ● Raster1900 1.0 ● Raster1100 ● Raster500 ● ● ● ● ● ● ● ● Raster100 ● ●● ● ● ● 0.5 ● ● ● ● ● ● ● ● ● ● ●●● ● ● ● ● ●● ● ● ●● ● Time to Compute (Seconds) ● ●●● ● ● ● ● ● ● ● ● ● ● ●●● ● ● ● ● ● ● ● ● ● ● ● ● ● ●● ● ● ● ● ●● ● ● ●● ● ●● ● ● ● ● ● ● ●● ● ● ● ●● ● ● ● ● ● ●● ● ●● ● ● ● ● ● ● ● ● ●● ● ● ●● ● ●●● ● ●●● ● ● ● ● ● ●● ● ● ● ● ●● ● ● ● ● ● ●●● ● ● ● ● ● ●● ● ●● ● ● ● ● ●● ● ● ● ● ● ● ● ● ● ● ●●● ●● 0.0 ● ● ● ●●

1 50 100 150 200 Test Number

Figure 4.17: A comparison of the processing times of 200 pairs of objects. We consider vector objects, and raster objects with a pixel width of 100, 500, 1100, and 1900.

4.4.1 Limitations

While we saw in our tests that the new algorithm is capable of producing accu- rate results, there are some limitations. The current data structure containing the objects is not designed for use with objects with holes or consisting of multiple parts. Additionally, the current implementation will not allow for a vertex of one object to lie perfectly on the edge of another object. There are many cases in which this will work, but in certain circumstances this form of edge-vertex intersection will produce incorrect results. Because of this limitation, it is not possible to test objects with the Phi Groups marked by an asterisk in Figure 2.2.

70 Finally, the algorithm to detect where the edges of the objects intersect fails in some cases. This algorithm was provided by another student, and the work is still ongoing. In testing, failures occur when an edge intersects with a perfectly horizontal edge.

4.5 Conclusion

In this chapter, we have introduced the first algorithm to calculate the φ-descriptor in the case of 2D vector objects. We have randomly 300 generated pairs of 2D vector objects, computed the 2D vector φ-descriptor for each of the pairs using the new algorithm, converted the pairs of vector objects to pairs of to raster objects with various image resolutions, computed the corresponding 2D raster φ-descriptors, and compared the vector and raster descriptors. We have quantified and plotted the sim- ilarities of te descriptors using two similarity measures. Our results have shown that in most cases the vector and raster descriptors were very similar as expected, and; the higher the resolution of the raster image the higher the similarity. We have examined the cases with poor similarity and found them to be cases with very thin regions that could not be properly rasterized, i.e., the low similarity scores were due to data loss in the conversion, not a fault of either φ-descriptor algorithm. We have also dis- cussed the current limitations of the implementation. Applications of this work are 2D vector objects where a powerful RPD is required to encapsulate a great amount of spatial relationship information. Our motivation was to show that the φ-descriptor is a capable successor to the force histogram, and is equally versatile.

4.5.1 Future Work

The limitations of the implementation should be addressed with future work. The issue with the intersection algorithm should be easy to correct, as it appears to be a minor bug with floating point errors. Correcting the other two limitations is a matter

71 of adjusting the data structures containing the objects. Further testing could involve comparing the computation times of the φ-descriptor and force histogram using 2D vector objects. We can then extend the algorithm to calculate the φ-descriptor in the case of 2D vector objects to also accept 3D vector objects.

Acknowledgments and Contributions

The concept for this algorithm was presented by Dr. Matsakis, who provided a sketch of expected output, and recommended to divide the objects at key locations such as intersections and local extrema. The implementation for the φ-descriptor in the case of 2D raster images was also provided by Dr. Matsakis, as well as the equations for similarity measures between the descriptors. During the majority of the testing a brute force test was used to find intersections between two objects. However this was replaced at some point by a more efficient algorithm implemented by another student, Tyler Laforet, for is CIS*5900 project.

72 Chapter 5

Conclusions and future work

5.1 Conclusions

In this thesis, we have introduced two new algorithms related to the computation of RPDs in the case of vector objects. We aimed to improve the efficiency of the force histogram in the case of 3D vector objects by providing a direction set designed for this purpose. We also aimed to take a step towards proving that the φ-descriptor is as versatile as the force histogram by providing a first algorithm to calculate the φ-descriptor in the case of 2D vector objects. We have introduced a new variant of the problem of evenly distributing points over a sphere, as well as provided a first solution we call the great circles distribution. The new variant requires that the distribution be as even as possible, and that the number of great circles to contain the points be as low as as possible. We compared the great circles distribution to various existing distributions using three different evenness measures. The main purpose of this new distribution was for use as a direction set for 3D vector RPDs, like the force histogram. The new distribution has greatly reduced the number of great circles required to contain the points, meaning the computation of the 3D vector RPDs will be more efficient. The great circles distribution is capable of distributing a number of points n = 6k2 for any positive integer k. We have also introduced the first algorithm to calculate the φ-descriptor in the case of 2D vector objects. This new algorithm was implemented and tested on ran- domly generated pairs of polygons and the results were compared against the output

73 of the φ-descriptor in the case of the corresponding 2D raster objects. The outcome indicated good similarity for the vast majority of test cases, with some poor results due to conversion from vector to raster objects. The current implementation of this new algorithm has some limitations: no vertex should lie directly on an edge of the other object, and objects must not be made of multiple components, or contain holes.

5.2 Future work

Future work for the great circles distribution would be to attempt to improve evenness, or lower the number of great circles needed to contain all the points of the distribution. Future work for the φ-descriptor in the case of 2D vector objects would be to remove the current limitations. For example, objects with holes or made of multiple components should become compatible by modifying the data structure storing the objects. Tests could also be run to compare the processing times of the φ-descriptor and force histogram in the case of 2D vector objects. A natural next step is to extend the φ-descriptor algorithm for 2D objects de- scribed in Chapter 4 to 3D vector objects, using the direction set described in Chapter 3. At that point, the processing times of the φ-descriptor and force histogram in the case of 3D vector objects could be compared as well.

74 Bibliography

[1] J. Reed, M. Naeem, and P. Matsakis, “A first algorithm to calculate force his- tograms in the case of 3d vector objects,” in Proceedings of the 3rd Interna- tional Conference on Pattern Recognition Applications and Methods, pp. 104– 112, SCITEPRESS-Science and Technology Publications, Lda, 2014.

[2] P. Matsakis, M. Naeem, and J. Francis, “Models of spatial relationships based on the φ-descriptor,” IEEE Trans. on Fuzzy Systems., 2018.

[3] J. Freeman, “The modelling of spatial relations,” Computer graphics and image processing, vol. 4, no. 2, pp. 156–171, 1975.

[4] K. Miyajima and A. Ralescu, “Spatial organization in 2d segmented images: representation and recognition of primitive spatial relations,” Fuzzy Sets and Systems, vol. 65, no. 2-3, pp. 225–236, 1994.

[5] M. Naeem and P. Matsakis, “Relative position descriptors - a review,” ICPRAM 2015 - 4th International Conference on Pattern Recognition Applications and Methods, Proceedings, vol. 1, pp. 286–295, 01 2015.

[6] J. M. Keller and X. Wang, “Comparison of spatial relation definitions in com- puter vision,” in Proceedings of 3rd International Symposium on Uncertainty Modeling and Analysis and Annual Conference of the North American Fuzzy Information Processing Society, pp. 679–684, IEEE, 1995.

[7] J. M. Keller and X. Wang, “Learning spatial relationships in computer vision,” in Proceedings of IEEE 5th International Fuzzy Systems, vol. 1, pp. 118–124, IEEE, 1996.

75 [8] R. Krishnapuram, J. M. Keller, and Y. Ma, “Quantitative analysis of proper- ties and spatial relations of fuzzy image regions,” IEEE Transactions on fuzzy systems, vol. 1, no. 3, pp. 222–233, 1993.

[9] P. Matsakis, L. Wendling, and J. Ni, “A general approach to the fuzzy modeling of spatial relationships,” in Methods for handling imperfect spatial information, pp. 49–74, Springer, 2010.

[10] P. Matsakis and L. Wendling, “A new way to represent the relative position between areal objects,” IEEE Transactions on pattern analysis and machine intelligence, vol. 21, no. 7, pp. 634–643, 1999.

[11] P. Matsakis, M. Naeem, and F. Rahbarnia, “Introducing the phi-descriptor - a most versatile relative position descriptor,” in ICPRAM, 2015.

[12] J. F. Allen, “Maintaining knowledge about temporal intervals,” in Readings in qualitative reasoning about physical systems, pp. 361–372, Elsevier, 1990.

[13] P. Matsakis and D. Nikitenko, “Combined extraction of directional and topolog- ical relationship information from 2d concave objects,” in Fuzzy modeling with spatial information for geographic problems, pp. 15–40, Springer, 2005.

[14] M. Skubic, P. Matsakis, G. Chronis, and J. Keller, “Generating multi-level lin- guistic spatial descriptions from range sensor readings using the histogram of forces,” Autonomous Robots, vol. 14, pp. 51–69, Jan 2003.

[15] D. Recoskie, T. Xu, and P. Matsakis, “A general algorithm for calculating force histograms using vector data.,” in ICPRAM (1), pp. 86–92, 2012.

[16] J. Reed, M. Naeem, and P. Matsakis, “A first algorithm to calculate force his- tograms in the case of 3D vector objects,” pp. 104–112, 2014.

[17] E. B. Saff and A. B. Kuijlaars, “Distributing many points on a sphere,” The mathematical intelligencer, vol. 19, no. 1, pp. 5–11, 1997.

76 [18] G. Darvas, “From viruses to molecules,” Symmetry: Cultural-historical and ontological aspects of science-arts relations The natural and man-made world in an interdisciplinary approach, pp. 215–241, 2007.

[19] S. Smale, “Mathematical problems for the next century,” The Mathematical In- telligencer, vol. 20, no. 2, pp. 7–15, 1998.

[20] J. J. Thomson, “XXIV. On the structure of the : an investigation of the stability and periods of oscillation of a number of corpuscles arranged at equal in- tervals around the circumference of a circle; with application of the results to the theory of atomic structure,” The London, Edinburgh, and Dublin Philosophical Magazine and Journal of Science, vol. 7, no. 39, pp. 237–265, 1904.

[21] P. Bourke, “Distributing points on a sphere,” 1996. last accessed February, 1, 2017.

[22] A. Semechko, “Uniform sampling of a sphere,” 2012.

[23] D. Jones, M. Horsfield, and A. Simmons, “Optimal strategies for measuring diffusion in anisotropic systems by magnetic resonance imaging,” Magn Reson Med, vol. 42, no. 3, 1999.

[24] R. Deriche, J. Calder, and M. Descoteaux, “Optimal real-time q-ball imaging using regularized kalman filtering with incremental orientation sets,” Medical image analysis, vol. 13, no. 4, pp. 564–579, 2009.

[25] D. C. Peters, F. R. Korosec, T. M. Grist, W. F. Block, J. E. Holden, K. K. Vigen, and C. A. Mistretta, “Undersampled projection reconstruction applied to mr angiography,” Magnetic Resonance in Medicine, vol. 43, no. 1, pp. 91–101, 2000.

[26] A. W. Anderson, “Measurement of fiber orientation distributions using high

77 angular resolution diffusion imaging,” Magnetic Resonance in Medicine, vol. 54, no. 5, pp. 1194–1206, 2005.

[27] P. Brass, W. O. Moser, and J. Pach, Research problems in discrete geometry. Springer Science & Business Media, 2006.

[28] R. Bauer, “Distribution of points on a sphere with application to star catalogs,” Journal of Guidance, Control, and Dynamics, vol. 23, no. 1, pp. 130–137, 2000.

[29] C. G. Koay, “Analytically exact spiral scheme for generating uniformly dis- tributed points on the unit sphere,” Journal of Computational Science, vol. 2, pp. 88–91, Mar. 2011.

[30] E. A. Rakhmanov, E. Saff, and Y. Zhou, “Minimal discrete energy on the sphere,” Math. Res. Lett, vol. 1, no. 6, pp. 647–662, 1994.

[31] C. G. Koay, “A simple scheme for generating nearly uniform distribution of antipodally symmetric points on the unit sphere,” Journal of Computational Science, vol. 2, pp. 377–381, Dec. 2011.

[32] M. K. Arthur, “Point Picking and Distributing on the Disc and Sphere,” tech. rep., DTIC Document, 2015.

[33] L.-C. Chang, E. El-Araby, V. Q. Dang, and L. H. Dao, “GPU acceleration of nonlinear diffusion tensor estimation using CUDA and MPI,” Neurocomputing, vol. 135, pp. 328–338, 2014.

[34] C. King III, W. R. Brown, M. J. Geller, and S. J. Kenyon, “Identifying star streams in the Milky Way halo,” The Astrophysical Journal, vol. 750, no. 1, pp. 81–89, 2012.

[35] J. C. Ranasinghesagara, C. K. Hayakawa, M. A. Davis, A. K. Dunn, E. O. Potma, and V. Venugopalan, “Rapid computation of the amplitude and phase of tightly

78 focused optical fields distorted by scattering particles,” J.of the Optical Society of America A, vol. 31, no. 7, pp. 1520–1530, 2014.

[36] S. Santis, Y. Assaf, C. J. Evans, and D. K. Jones, “Improved precision in CHARMED assessment of white matter through sampling scheme optimization and model parsimony testing,” Magnetic resonance in medicine, vol. 71, no. 2, pp. 661–671, 2014.

[37] D. J. Wales, H. McKay, and E. L. Altschuler, “Defect motifs for spherical topolo- gies,” Physical Review B, vol. 79, no. 22, p. 224115, 2009.

[38] D. J. Wales and S. Ulker, “Structure and dynamics of spherical crystals charac- terized for the Thomson problem,” Physical Review B, vol. 74, no. 21, p. 212101, 2006.

[39] M. K. Arthur, “Point picking and distributing on the disc and sphere,” report ARL-TR-7333, Army Research Lab, 2015. 58 Pages.

[40] R. Sadourny, “Conservative finite-difference approximations of the primitive equations on quasi-uniform spherical grids,” Monthly Weather Review, vol. 100, no. 2, pp. 136–144, 1972.

[41] R. D. Nair, S. J. Thomas, and R. D. Loft, “A discontinuous galerkin transport scheme on the cubed sphere,” Monthly Weather Review, vol. 133, no. 4, pp. 814– 828, 2005.

[42] M. Ranˇci´c,R. Purser, and F. Mesinger, “A global shallow-water model using an expanded spherical cube: Gnomonic versus conformal coordinates,” Quarterly Journal of the Royal Meteorological Society, vol. 122, no. 532, pp. 959–982, 1996.

[43] C. Ronchi, R. Iacono, and P. S. Paolucci, “The “cubed sphere”: a new method for the solution of partial differential equations in spherical geometry,” Journal of Computational Physics, vol. 124, no. 1, pp. 93–114, 1996.

79 [44] M. Taylor, J. Tribbia, and M. Iskandarani, “The spectral element method for the shallow water equations on the sphere,” Journal of Computational Physics, vol. 130, no. 1, pp. 92–108, 1997.

[45] D. P. Hardin, T. Michaels, and E. B. Saff, “A comparison of popular point configurations on S2,” Dolomites Research Notes on Approximation, vol. 9, no. 1, pp. 16–49, 2016.

[46] M. Skubic, D. Perzanowski, S. Blisard, A. Schultz, W. Adams, M. Bugajska, and D. Brock, “Spatial language for human-robot dialogs,” IEEE Transactions on Systems, Man, and Cybernetics, Part C (Applications and Reviews), vol. 34, no. 2, pp. 154–167, 2004.

[47] C.-R. Shyu, M. Klaric, G. J. Scott, A. S. Barb, C. H. Davis, and K. Palaniap- pan, “GeoIRIS: Geospatial information retrieval and indexing system—content mining, semantics modeling, and complex queries,” IEEE Transactions on Geo- science and Remote Sensing, vol. 45, no. 4, pp. 839–852, 2007.

[48] O. Sjahputera and J. M. Keller, “Scene matching using f-histogram-based fea- tures with possibilistic c-means optimization,” Fuzzy Sets and Systems, vol. 158, no. 3, pp. 253–269, 2007.

[49] I. Debled-Rennesson and L. Wendling, “Combining force histogram and discrete lines to extract dashed lines,” in Pattern Recognition (ICPR), 2010 20th Inter- national Conference on, pp. 1574–1577, IEEE, 2010.

[50] C. Vaduva, I. Gavat, and M. Datcu, “Latent Dirichlet allocation for spatial anal- ysis of satellite images,” IEEE Transactions on Geoscience and Remote Sensing, vol. 51, no. 5, pp. 2770–2786, 2013.

[51] M. Li, A. Stein, W. Bijker, and Q. Zhan, “Urban land use extraction from very high resolution remote sensing imagery using a Bayesian network,” ISPRS Journal of Photogrammetry and Remote Sensing, vol. 122, pp. 192–205, 2016.

80 [52] D. J. Wales and S. Ulker, “The cambridge cluster database: global minima for the Thomson problem.” 2006. Last accessed November 16, 2017. http://www- wales.ch.cam.ac.uk/ wales/CCD/Thomson/table.html.

[53] C. G. Koay, “A simple scheme for generating nearly uni- form distribution of antipodally symmetric points on the unit sphere.” 2011. Last accessed November 16, 2017. https://sites.google.com/site/hispeedpackets/Home/antipodallysymmetricpointset.

[54] J. D. h. Page, “Algorithm to find the area of a polygon.”

[55] G. VanˇeˇcekJr, “Spatial partitioning of a polygon by a plane,” in Graphics Gems V, pp. 386–393, Elsevier, 1995.

[56] https://stackoverflow.com/questions/8997099/algorithm-to-generate-random- 2d polygon, “Algorithm to generate random 2d polygon.”

81