scieee AI-readable full text Open interactive document viewer

R implementation of a polyhedral approximation to a 3D set of points using the α-shape

Lafarge, Thomas; Pateiro López, Beatriz; Possolo, Antonio; Dunkers, Joy P.

Abstract

This work presents the implementation in R of the α-shape of a nite set of points in the three-dimensional space R3. This geometric structure generalizes the convex hull and allows to recover the shape of non-convex and even non-connected sets in 3D, given a random sample of points taken into it. Besides the computation of the α-shape, the R package alphashape3d provides users with tools to facilitate the three-dimensional graphical visualization of the estimated set as well as the computation of important characteristics such as the connected components or the volume, among others

Full text

JSS Journal of Statistical Software January 2014, Volume 56, Issue 4. http://www.jstatsoft.org/ RImplementation of a Polyhedral Approximation to a 3D Set of Points Using the α-Shape Thomas Lafarge National Institute of Standards and Technology Beatriz Pateiro-L´opez Universidad de Santiago de Compostela Antonio Possolo National Institute of Standards and Technology Joy P. Dunkers National Institute of Standards and Technology Abstract This work presents the implementation in Rof the α-shape of a finite set of points in the three-dimensional space R3. This geometric structure generalizes the convex hull and allows to recover the shape of non-convex and even non-connected sets in 3D, given a random sample of points taken into it. Besides the computation of the α-shape, the Rpackage alphashape3d provides users with tools to facilitate the three-dimensional graphical visualization of the estimated set as well as the computation of important characteristics such as the connected components or the volume, among others. Keywords: set estimation, 3D surface reconstruction, α-convexity, α-shape, R. 1. Introduction Point sets are a fundamental source of information in many disciplines: they may be samples from probability distributions, portions of realizations of point processes observed within bounded sampling windows, or have substantive meaning (for example, landmarks in industrial parts or in biological structures). In many cases, a primary goal is to recover the size and shape of the set the points originate from (set estimation). In some applications the set is known but a sample of points is taken from it anyway, and used as a discrete approximation that facilitates the estimation of selected geometric attributes of the set (morphometry). Besides the long-standing models for two-dimensional (2D) data, there is now an increasing 2alphashape3d: Polyhedral Approximation to a 3D Set of Points in R interest in modeling techniques for three-dimensional (3D) data. Widely available technologies for measurement of 3D structures—including 3D laser-scanning, confocal microscopy, and computed tomography from nano to macro scales—are generating high-quality digital datasets that may be point clouds, or sets whose geometry can be probed using point clouds, in cellular biology, medicine, material science, engineering, etc. Consequently, a rich branch of image analysis has been developing rapidly to deal with the reconstruction of 3D objects from point clouds, and to study geometrical attributes after discretization by sampling with point clouds. Statistical morphometry seeks to characterize the variability of shape and size, which is essential in a wide range of disciplines that include biology, material science, geology, archaeology, geography, etc. We refer to Small (1996) and Grenander and Miller (2007) for an extensive review of the methods and applications of shape analysis. See also Claude (2008) for a guide on how to perform morphometrics with R. The geometric characterization of an object includes the computation of volumes and surface areas, surface roughness, deviations from convexity, porosity and permeability, among many other attributes, in many cases from points sampled within the object. In practice, the user defines a sampling procedure to obtain points in the set of interest, and thus the problem relates to the problem of set estimation. The goal of set estimation is to produce estimates of compact subsets of an Euclidean space based on random samples of points from probability distributions whose supports are those sets, and then to study the statistical properties of the corresponding estimators (asymptotic properties, types of convergence, convergence rates, etc.). Cuevas and Fraiman (2009) surveys the most relevant theory on set estimation. There are different geometrical structures that can capture the shape of a set from a sample of points taken from it. The extent to which these structures manage faithfully to reproduce the original set depends heavily on the geometrical characteristics of the set. For instance, if the original set is convex, the convex hull of the sample is the natural estimator. See Geffroy (1964), R´enyi and Sulanke (1963,1964), Schneider (1988), D¨ umbgen and Walther (1996) for results about the convex hull estimator. However, in many applications the sets or objects of interest are not strictly convex, but only approximately so. There is, therefore, a need to define relaxed convexity shape restrictions. The α-convexity is one such restriction that mildly relaxes the assumption of convexity, and does so in a tunable manner (determined by the value of the parameter α): it appears in the literature on set estimation, see Walther (1997,1999), Rodr´ıguez-Casal (2007). By analogy with the characterization of a convex set as the intersection of half-spaces defined by planes tangent to the set, a set is said to be α-convex if it can be expressed as an intersection of the complements of open balls of radius αnot intersecting the set. Section 2provides details on α-convex sets. The so-called α-convex hull of the sample is a suitable estimator of α-convex sets (think of what is left if carving out all the space with a spherical scoop of radius αwithout removing any of the points in the sample). Rodr´ıguez-Casal (2007) studies the asymptotic performance of this estimator. The boundary of the α-convex hull comprises arcs of circles (in 2D), or spherical caps (in 3D), and intersections thereof. If now we approximate the boundary of the α-convex hull by a polygonal curve (in 2D) or by a polyhedral surface (in 3D), then we get another object that approximates the original set, called the α-shape. Edelsbrunner, Kirkpatrick, and Seidel (1983) defined it in the case of R2, and Edelsbrunner and M¨ ucke (1994) generalized it to three-dimensional Euclidean space. The α-shapes have been widely used in several different Journal of Statistical Software 3 fields: for example, to characterize biological systems, and the structure, surface and cavities of molecules and proteins, as described by Liang, Edelsbrunner, Fu, Sudhakar, and Subramaniam (1998a,b), Edelsbrunner and Facello (1998), Zhou and Yan (2010), among others. Also in cosmology, by van de Weygaert, Platen, Vegter, Eldering, and Kruithof (2010), to study the topology of the distribution of galaxies. Vauhkonen, Tokola, Maltamo, and Packal´en (2008) describe applications of α-shapes in remote sensing, where tree characteristics are determined from laser scanning data. There are also connections between α-shapes and pattern recognition and clustering techniques. Given a porous material, the α-shape of a sample of points drawn from the material can be used to characterize the geometry of the pores; alternatively, the α-shape of a sample of points drawn from the voids can be used to study the permeability of the material. It is becoming increasingly clear that R(RCore Team 2013) has grown to become one of the most powerful tools for statistical data analysis, and in fact the lingua franca for the interchange of ideas and methods in computational statistics and probability. Ris a highlevel language that offers powerful graphical capabilities and a wide variety of facilities for statistical modeling and data analysis in many fields of research. Many of the techniques discussed in this paper have been developed over the last couple of decades, and there exist several Rpackages that, in one form or another, address issues of set estimation. For example, the convex hull of a set of points in d-dimensional Euclidean space can be computed using functions in package geometry (Barber, Habel, Grasman, Gramacy, Stahel, and Sterratt 2013). Objects analyzed in the disciplines mentioned above are mostly two-dimensional or three-dimensional. The two-dimensional α-shape and the α-convex hull are implemented in the Rpackage alphahull by Pateiro-L´opez and Rodr´ıguez-Casal (2011). Edelsbrunner et al. (1983) describe the algorithm for the computation of the α-shape and α-convex hull in 2D. Pateiro-L´opez and Rodr´ıguez-Casal (2010) provide further details on the package and applications. However, and in spite of its potential usefulness in statistical analysis, the α-shape in 3D had not yet been implemented in R. Cognizant of the importance of the development of a free, open-source software environment for statistical computing, we have produced the Rpackage alphashape3d, see Lafarge and Pateiro-L´opez (2013). The paper is organized as follows. In Section 2we provide some background in set estimation theory and describe the estimator under study, the α-shape of a random sample of points in the three-dimensional Euclidean space. In Section 3we briefly describe the algorithm by Edelsbrunner and M¨ ucke (1994) and give the details about its implementation in R. Section 4 describes an application of α-shapes to the characterization and quantification of geometric attributes of a polymeric scaffold used to grow biological tissues in culture. Further computational details are given in Section 5. 2. The α-shape in 3D This work is based on the computation of α-shapes in R3as defined by Edelsbrunner and M¨ ucke (1994). The α-shape is computationally practicable, and it is closely related to the α-convex hull estimator, which has been studied predominantly from a theoretical viewpoint. As mentioned in Section 1, in order to estimate an unknown set effectively, from points drawn from it, some geometrical assumptions have to be made. Even though convex sets have many useful and well-known properties, restricting attention to estimators that are convex sets rules out consideration of many sets of great practical interest. There are meaningful extensions of 4alphashape3d: Polyhedral Approximation to a 3D Set of Points in R α = 0.04 0.0 0.2 0.4 0.6 0.8 1.0 0.0 0.2 0.4 0.6 0.8 1.0 ● ● ● ● ●● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ●● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ●● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ●● ● ● ● ● ● ● ● ●● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ●● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ●● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ●● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● α = 0.2 0.0 0.2 0.4 0.6 0.8 1.0 0.0 0.2 0.4 0.6 0.8 1.0 ● ● ● ● ●● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ●● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ●● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ●● ● ● ● ● ● ● ● ●● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ●● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ●● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● α = 1 0.0 0.2 0.4 0.6 0.8 1.0 0.0 0.2 0.4 0.6 0.8 1.0 ● ● ● ● ●● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ●● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ●● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ●● ● ● ● ● ● ● ● ●● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ●● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ●● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● Figure 1: In pink, boundary of the α-convex hulls of a uniform random sample of size n= 300 on a ring in R2for different values of α. In blue, the corresponding α-shapes. the notion of convexity, such as α-convexity. A set A⊂Rdis said to be α-convex, for α > 0, if A=Cα(A),where Cα(A) = \ {˚ B(x,α): ˚ B(x,α)∩A=∅} ˚ B(x, α)c(1) is called the α-convex hull of A. In (1), ˚ B(x, α) denotes the open ball with center xand radius α.Walther (1999) describes properties of α-convex sets and relations between convexity and α-convexity. Let Sbe a nonempty compact subset in Rd, equipped with the norm k·k. Assume that we are given a random sample Xn={X1, . . . , Xn}from a probability distribution PX on Rdwith support S. The goal is to approximate Sbased on the sample. If we assume that the set Sis α-convex then the natural estimator of Sis Cα(Xn), the α-convex hull of the sample. Rodr´ıguez-Casal (2007) characterizes the performance of the estimator. In Figure 1 we represent the α-convex hull estimator in the two-dimensional case. If we straighten the α-convex hull in Figure 1by substituting straight edges for the circular arcs, we obtain a straight line graph known as α-shape: this is computationally more practicable than the α-convex hull. Edelsbrunner et al. (1983) give a formal definition of the α-shape in R2. In R3, one can visualize the α-convex hull estimator by thinking of a sphere of radius α scooping up space around the points without removing any of them. By replacing each spherical cap with the largest triangle circumscribed by the cap we obtain the α-shape, see Figure 2. The formal definition of the α-shape in 3D can be found in Edelsbrunner and M¨ ucke (1994). It can be computed from the α-complex of the sample, also defined in Edelsbrunner and M¨ ucke (1994), which is a subcomplex of the Delaunay triangulation. The α-shape is the polytope (in a general sense) formed by the union of all simplices of the α-complex. Further details are given in Section 3. The value of αcontrols the spatial scale of the shape of the estimator. As αdecreases, the α-shape shrinks and cavities appear among the sample points. As αtends to ∞, the α-shape tends to the the convex hull of the sample, see Figure 2. This emphasizes the fact that the α-shape can be considered a generalization of the convex hull. The flexibility that varying αaffords is very useful to characterize the geometry of porous materials. When studying some of the properties of these materials, it may be preferable to focus on the α-shape of the voids: for example, to characterize the geometry of tunnels that link different pores, as will be illustrated in Section 4. Journal of Statistical Software 5 Figure 2: From left to right, α-shapes of a point cloud in R3for increasing values of α. 3. Implementation The Rpackage alphashape3d comprises functions to compute, represent and display the αshape of a given sample of points in three-dimensional Euclidean space. We restrict ourselves to point sets in R3because we are mainly motivated by the applications of the α-shape in 3D, even though the definition of the α-shape can be generalized to higher dimensions (increasing the difficulty of the implementation). The main function in the package is ashape3d, that implements in Rthe algorithm specified by Edelsbrunner and M¨ ucke (1994). The α-shape is computed from the three-dimensional Delaunay triangulation of the point set. Section 3.1 describes the computation of that triangulation, and Section 3.2 describes the computation of the α-shape. Section 3.3 gives details about the three-dimensional graphical representation of the α-shape. Section 3.4 describes functions to compute and visualize the connected components of the α-shape. Section 3.5 describes other important features of the α-shape that can be computed with functions in the package alphashape3d. 3.1. Delaunay triangulation in 3D: The package geometry The computation of the α-shape is closely related to the construction of the Delaunay triangulation of the given point set. Edelsbrunner et al. (1983) makes precise the relationship that exists between these two geometric structures in the bi-dimensional case by proving that the α-shape is a subgraph of the Delaunay triangulation. This simplifies the computation of the α-shape since we only have to consider the edges of the Delaunay triangulation as candidates to form the α-shape. The relationship between α-shape and Delaunay triangulation is also decisive in R3. The problem of triangulation in R3arises in the decomposition of three-dimensional objects, for example, in solid modeling. The Delaunay triangulation is an essential geometric structure with a large number of applications, such as mesh generation and cluster analysis, crystallography, metallurgy, image processing, etc. For in-depth discussions of these problems we refer the reader to Aurenhammer (1991) and Preparata and Shamos (1985). Similarly to the two-dimensional case, the Delaunay triangulation in R3is defined as the dual of the Voronoi diagram (or, tessellation). Recall that the Voronoi diagram of a finite sample of points is the partition of space into cells such that each cell comprises the points which are 6alphashape3d: Polyhedral Approximation to a 3D Set of Points in R ● ● ● ● ● ● ● ● ● ● Figure 3: The left panel shows the Voronoi diagram of a set of point in R2: each point has an associated closed and convex Voronoi polygon (whose boundary is outlined in green), delimited by Voronoi edges abutting on Voronoi vertices; the corresponding Delaunay triangulation is drawn in red. The right panel shows the Delaunay triangulation of a uniform random sample of size n= 50 drawn from the unit cube in R3: the Delaunay diagram comprises tetrahedra and their triangular faces, edges and vertices; a tetrahedron’s circumsphere, drawn in gray, contains no data points besides those at its vertices. closer to one particular sample point than to any other sample point. In the simplest, twodimensional case, the data are a sample of points in the plane, which are the Voronoi point sites. Each point site has associated a closed and convex Voronoi cell, defined by an open and convex Voronoi region, Voronoi edges and Voronoi vertices, as illustrated in Figure 3. In R3, each Voronoi cell is defined by a Voronoi region that is a three-dimensional convex polyhedron, Voronoi facets, Voronoi edges, and Voronoi vertices. The dual complex Delaunay “triangulation” consists of Delaunay tetrahedra and their triangular faces, edges and vertices, hence may more properly be called a “tetrahedralization”. An important feature in the Delaunay triangulation is that the circumsphere of each tetrahedron includes no other point sites (empty sphere property). The centers of these empty circumspheres are just the vertices of the Voronoi diagram, see Figure 3.Okabe, Boots, Sugihara, and Chiu (2009) provide an extensive discussion on the properties of Voronoi diagrams, Delaunay triangulations and their many applications in computational geometry. It should be noted that for a set of npoints in R3the number of Delaunay tetrahedra generally is proportional to n2. In R, the Delaunay triangulation in R3can be computed with the package geometry (Barber et al. 2013), which makes the qhull library (Barber, Dobkin, and Huhdanpaa 1996) available in R. The function qhull computes convex hulls, Delaunay triangulations, Voronoi vertices, farthest-site Voronoi vertices, and half-space intersections. Barber et al. (1996) describe the Quickhull algorithm and review literature on the subject exhaustively. Discussion on efficient methods for the computation of Delaunay triangulation and Voronoi diagrams can be found in Aurenhammer and Klein (2000) and references therein. The function delaunayn in package geometry plays an important role in the computation Journal of Statistical Software 7 Figure 4: Point cloud of size n= 4000 within two linked tori. of the α-shape described in Section 3.2. Given a sample of points in R3, it returns for each tetrahedron in the triangulation the indices of the sample points defining the tetrahedron. 3.2. The function ashape3d Here we describe the function ashape3d, included in the package alphashape3d, that implements the algorithm to construct the three-dimensional α-shape in R. The function ashape3d computes the α-shape of a given sample Xnin R3for given values of α > 0. As an example to illustrate the use of the function we consider a point cloud of size n= 4000 within two linked tori, see Figure 4. Using function rtorus, we generated a uniform random sample of size 2000 in each of two tori with minor radius r= 0.5 and major radius R= 2. The computation of the α-shape requires that the input points be in the so-called general position (no quadruplet of points lies on the same plane, no quintuplet lies on the same sphere, and, for any particular α, the smallest sphere through any two, three, or four points has radius different from α). The function determines whether the given points are in such general position, and it gives the user the option of slightly disturbing their coordinates to remove the degeneracy and compute the α-shape, see Section 5. R> n <- 4000 R> T1 <- rtorus(n/2, 0.5, 2) R> T2 <- rtorus(n/2, 0.5, 2, ct = c(2, 0, 0), rotx = pi/3) R> x <- rbind(T1, T2) R> points3d(x, col = 4) We compute the α-shape for α= 0.3 and α= 0.5. R> alphashape3d <- ashape3d(x, alpha = c(0.3, 0.5)) R> class(alphashape3d) [1] "ashape3d" R> names(alphashape3d) [1] "tetra" "triang" "edge" "vertex" "x" "alpha" 8alphashape3d: Polyhedral Approximation to a 3D Set of Points in R The output of the function is an object of class ‘ashape3d’. The components xand alpha store the input information. For each simplex (tetrahedron, triangle, edge or vertex) in the threedimensional Delaunay triangulation there is a single interval so that the simplex is a face of the α-shape if and only if αis contained in this interval. Moreover, see Table I in Edelsbrunner and M¨ ucke (1994)1, each interval can be broken into three parts that classify a simplex as an interior, regular or singular simplex of the α-complex. As defined in Edelsbrunner and M¨ ucke (1994), a simplex in the α-complex is interior if it does not belong to the boundary of the α-shape. A simplex in the α-complex is regular if it is part of the boundary of the α-shape and bounds some higher-dimensional simplex in the α-complex. A simplex in the α-complex is singular if it is part of the boundary of the α-shape but does not bound any higher-dimensional simplex in the α-complex. This classification allows us to identify the simplices that define the boundary of the α-shape. Throughout this paper, numerical results are listed as Rwould produce them by default, irrespective of whether all the digits reported are substantively significant. R> head(alphashape3d$tetra) v1 v2 v3 v4 rhoT fc:0.3 fc:0.5 2195 2600 2744 3321 7.0230556 0 0 2827 3068 3454 3945 115.7040464 0 0 2487 2600 2706 3321 0.3737607 0 1 945 987 1193 1212 6.1903426 0 0 987 1193 1212 1564 1.9255532 0 0 1016 1307 1806 2578 21.7796659 0 0 For each tetrahedron of the 3D Delaunay triangulation, the matrix tetra stores the indices of the sample points defining the tetrahedron (columns 1 to 4), a value rhoT that defines the intervals for which the tetrahedron belongs to the α-complex (column 5) and for each αa value (1 or 0) indicating whether the tetrahedron belongs to the α-shape (columns 6 to last). Thus, for the sample in Figure 5(left), the tetrahedron defined by the points with indexes (2195,2600,2744,3321) belongs to the α-shape for α > 7.0231. R> head(alphashape3d$triang) tr1 tr2 tr3 on.ch attached rhoT muT MuT fc:0.3 fc:0.5 1 92 215 0 1 0.08494984 0.09002722 0.2210708 1 1 1 92 313 0 0 0.12766532 0.14948514 0.1673457 1 1 1 92 519 0 0 0.06895091 0.09002722 0.1479914 1 1 1 92 625 0 1 0.14687077 0.14799142 0.1494851 1 1 1 92 1333 0 1 0.16734568 0.16734572 0.1673663 1 1 1 92 1636 0 0 0.14244050 0.16736628 0.2210708 1 1 For each triangle of the 3D Delaunay triangulation, the matrix triang stores the indices of the sample points defining the triangle (columns 1 to 3), a value (1 or 0) indicating whether the triangle is on the convex hull (column 4), a value (1 or 0) indicating whether the triangle is attached or unattached2(column 5), values rhoT,muT and MuT that define the intervals for 1The end-points of these sub-intervals, ρT,µTand µTdefined in Edelsbrunner and M¨ ucke (1994), are stored in columns rhoT,muT and MuT, respectively. 2See nomenclature of Edelsbrunner and M¨ ucke (1994). Journal of Statistical Software 9 which the triangle belongs to the α-complex (columns 6 to 8) and for each αa value (0, 1, 2 or 3) indicating, respectively, that the triangle is not in the α-shape or it is interior, regular or singular (columns 9 to last). R> head(alphashape3d$edge) ed1 ed2 on.ch attached rhoT muT MuT fc:0.3 fc:0.5 [1,] 1 92 0 0 0.06281722 0.06895091 0.2210708 1 1 [2,] 1 215 0 0 0.07220062 0.07221194 0.3163063 2 1 [3,] 1 313 0 1 0.11899642 0.12371479 0.1673962 1 1 [4,] 1 365 0 0 0.03166164 0.10016329 0.2673887 1 1 [5,] 1 372 0 1 0.10734872 0.10883523 0.3107847 2 1 [6,] 1 519 0 0 0.05835185 0.06895091 0.1479944 1 1 For each edge of the 3D Delaunay triangulation, the matrix edge stores the indices of the sample points defining the edge (columns 1 and 2), a value (1 or 0) indicating whether the edge is on the convex hull (column 3), a value (1 or 0) indicating whether the edge is attached or unattached (column 4), values rhoT,muT and MuT that define the intervals for which the edge belongs to the α-complex (columns 5 to 7) and for each αa value (0, 1, 2 or 3) indicating, respectively, that the edge is not in the α-shape or it is interior, regular or singular (columns 8 to last). R> head(alphashape3d$vertex) v1 on.ch muT MuT fc:0.3 fc:0.5 [1,] 1 0 0.03166164 0.3163063 2 1 [2,] 2 0 0.06276595 0.2062490 1 1 [3,] 3 0 0.06117960 0.1659127 1 1 [4,] 4 0 0.07173660 1.8094574 2 2 [5,] 5 0 0.09143347 1.0523604 2 2 [6,] 6 0 0.07450637 0.2802244 1 1 For each sample point, the matrix vertex stores the index of the point (column 1), a value (1 or 0) indicating whether the point is on the convex hull (column 2), values muT and MuT that define the intervals for which the point belongs to the α-complex (columns 3 and 4) and for each αa value (1, 2 or 3) indicating, respectively, if the point is interior, regular or singular (columns 5 to last). 3.3. Graphical representation of the α-shape in 3D Graphical visualization is an essential part of data analysis and statistical modelling. An S3 plot method for ‘ashape3d’ objects performs 3D visualization of the α-shape. R> rgl.viewpoint(20) R> rgl.light(120, 60) R> bg3d("white") R> plot(alphashape3d, col = c(4, 4, 4), indexAlpha = "all") 16 alphashape3d: Polyhedral Approximation to a 3D Set of Points in R and edges of the object. Next, the coordinates of the vertices are listed and following these are the face descriptions. The following code saves the α-shape computed in our example for α= 0.3 as an OFF file. OFF files can be visualized and manipulated quite easily using 3D viewing programs. R> offFilename <- "alphashape3d.off" R> write("OFF", file = offFilename, append = FALSE, sep = " ") R> aux <- alphashape3d$triang R> tr <- aux[aux[, 9] == 2 | aux[, 9]==3, c("tr1", "tr2", "tr3")] R> write(c(dim(alphashape3d$x)[1], dim(tr)[1], 0), file = offFilename, + append = TRUE, sep = " ") R> write(t(alphashape3d$x), file = offFilename, ncolumns = 3, + append = TRUE, sep = " ") R> write(t(cbind(rep(3, dim(tr)[1]), tr - 1)), + file = offFilename, ncolumns = 4, append = TRUE, sep = " ") 5.3. Software The results in this document were obtained using R3.0.1 (RCore Team 2013). The alphashape3d package is available from the Comprehensive RArchive Network at http://CRAN. R-project.org/package=alphashape3d. This paper describes version 1.0-4 of the package. Acknowledgments This work has been partially supported by Spanish Grant MTM2008-03010 and the IAP research network grant no. P6/03 from the Belgian government (Beatriz Pateiro-L´opez), and by the Shape Metrology Innovations in Measurement Science from the National Institute of Standards and Technology (all the authors). Since the work is a work product of the National Institute of Standards and Technology, an agency of the U.S. federal government, it is not subject to copyright in the United States. We are much indebted to Girish Kumar (currently at the Food and Drug Administration, U.S. Department of Health and Human Services, formerly in the Polymers Division, Material Measurement Laboratory, National Institute of Standards and Technology) who obtained the images of the polymeric scaffold used in Section 4, and to Carl Simon and Tanya Farooque (Polymers Division, Material Measurement Laboratory, National Institute of Standards and Technology) for facilitating access to the digital data, and for suggesting substantively meaningful shape attributes to measure in polymeric scaffolds. Ris not a commercial product: it is a freely accessible software product. Its use here does not imply recommendation or endorsement by the National Institute of Standards and Technology, nor does it imply that it is necessarily the best available for the purpose. References Adler D, Murdoch D (2013). rgl: 3D Visualization Device System (OpenGL).Rpackage version 0.93.935, URL http://CRAN.R-project.org/package=rgl. Journal of Statistical Software 17 Aurenhammer F (1991). “Voronoi Diagrams – A Survey of a Fundamental Geometric Data Structure.” ACM Computing Surveys,23(3), 345–405. Aurenhammer F, Klein R (2000). “Voronoi Diagrams.” In Handbook of Computational Geometry, pp. 201–290. North-Holland, Amsterdam. Barber CB, Dobkin DP, Huhdanpaa H (1996). “The Quickhull Algorithm for Convex Hulls.” ACM Transactions on Mathematical Software,22(4), 469–483. URL http://www.qhull. org/. Barber CB, Habel K, Grasman R, Gramacy RB, Stahel A, Sterratt DC (2013). geometry: Mesh Generation and Surface Tesselation.Rpackage version 0.3-3, URL http://CRAN. R-project.org/package=geometry. Claude J (2008). Morphometrics with R. Springer-Verlag, New York. Cuevas A, Fraiman R (2009). “Set Estimation.” In WS Kendall, I Molchanov (eds.), New Perspectives on Stochastic Geometry, pp. 366–385. Oxford University Press. D¨ umbgen L, Walther G (1996). “Rates of Convergence for Random Approximations of Convex Sets.” Advances in Applied Probability,28(2), 384–393. Edelsbrunner H, Facello M (1998). “On the Definition and the Construction of Pockets in Macromolecules.” Discrete Applied Mathematics,88(1–3), 83–102. Edelsbrunner H, Kirkpatrick DG, Seidel R (1983). “On the Shape of a Set of Points in the Plane.” IEEE Transactions on Information Theory,29(4), 551–559. Edelsbrunner H, M¨ ucke EP (1994). “Three-Dimensional Alpha Shapes.” ACM Transactions on Graphics,13(1), 43–72. Geffroy J (1964). “Sur un Probl`eme d’Estimation G´eom´etrique.” Publications de l’Institut de Statistique de l’Universit´e de Paris,13, 191–210. Grenander U, Miller MI (2007). Pattern Theory: From Representation to Inference. Oxford University Press, Oxford. Lafarge T, Pateiro-L´opez B (2013). alphashape3d: Implementation of the 3D Alpha-Shape for the Reconstruction of 3D Sets from a Point Cloud.Rpackage version 1.0-3, URL http://CRAN.R-project.org/package=alphashape3d. Liang J, Edelsbrunner H, Fu P, Sudhakar PV, Subramaniam S (1998a). “Analytical Shape Computation of Macromolecules: I.” Proteins: Structure, Function and Bioinformatics, 33(1), 1–17. Liang J, Edelsbrunner H, Fu P, Sudhakar PV, Subramaniam S (1998b). “Analytical Shape Computation of Macromolecules: II. Inaccessible Cavities in Proteins.” Proteins: Structure, Function and Bioinformatics,33(1), 18–29. Marchette DJ (2004). Random Graphs for Statistical Pattern Recognition. John Wiley & Sons. 18 alphashape3d: Polyhedral Approximation to a 3D Set of Points in R Okabe A, Boots B, Sugihara K, Chiu SN (2009). Spatial Tessellations: Concepts and Applications of Voronoi Diagrams. Wiley Series in Probability and Statistics. John Wiley & Sons. Pateiro-L´opez B, Rodr´ıguez-Casal A (2010). “Generalizing the Convex Hull of a Sample: The RPackage alphahull.” Journal of Statistical Software,34(5), 1–28. URL http://www. jstatsoft.org/v34/i05/. Pateiro-L´opez B, Rodr´ıguez-Casal A (2011). alphahull: Generalization of the Convex Hull of a Sample of Points in the Plane.Rpackage version 0.2-1, URL http://CRAN.R-project. org/package=alphahull. Preparata FP, Shamos MI (1985). Computational Geometry: An Introduction. Texts and Monographs in Computer Science. Springer-Verlag. RCore Team (2013). R: A Language and Environment for Statistical Computing.RFoundation for Statistical Computing, Vienna, Austria. URL http://www.R-project.org/. R´enyi A, Sulanke R (1963). “¨ Uber die konvexe H¨ ulle von nzuf¨ allig gew¨ ahlten Punkten.” Zeitschrift f¨ ur Wahrscheinlichkeitstheorie und Verwandte Gebiete,2(1), 75–84. R´enyi A, Sulanke R (1964). “¨ Uber die konvexe H¨ ulle von nzuf¨ allig gew¨ ahlten Punkten. II.” Zeitschrift f¨ ur Wahrscheinlichkeitstheorie und Verwandte Gebiete,3(2), 138–147. Rodr´ıguez-Casal A (2007). “Set Estimation under Convexity Type Assumptions.” Annales de l’Institut Henri Poincar´e (B) Probabilit´es et Statistique,43(6), 763–774. Schneider R (1988). “Random Approximation of Convex Sets.” Journal of Microscopy,151(3), 211–227. Small CG (1996). The Statistical Theory of Shape. Springer Series in Statistics. Springer- Verlag. Tarjan R (1972). “Depth-First Search and Linear Graph Algorithms.” SIAM Journal on Computing,1(2), 146–160. van de Weygaert R, Platen E, Vegter G, Eldering B, Kruithof N (2010). “Alpha Shape Topology of the Cosmic Web.” In 2010 International Symposium on Voronoi Diagrams in Science and Engineering, pp. 224–234. IEEE Computer Society, Los Alamitos, CA. doi: 10.1109/ISVD.2010.24. Vauhkonen J, Tokola T, Maltamo M, Packal´en P (2008). “Effects of Pulse Density on Predicting Characteristics of Individual Trees of Scandinavian Commercial Species Using Alpha Shape Metrics Based on Airborne Laser Scanning Data.” Canadian Journal of Remote Sensing,34(S2), S441–S459. Walther G (1997). “Granulometric Smoothing.” The Annals of Statistics,25(6), 2273–2299. Walther G (1999). “On a Generalization of Blaschke’s Rolling Theorem and the Smoothing of Surfaces.” Mathematical Methods in the Applied Sciences,22(4), 301–316. Zhou W, Yan H (2010). “A Discriminatory Function for Prediction of Protein-DNA Interactions Based on Alpha Shape Modeling.” Bioinformatics,26(20), 2541–2548. Journal of Statistical Software 19 Affiliation: Beatriz Pateiro-L´opez Departamento de Estad´ıstica e Investigaci´on Operativa Facultad de Matem´aticas R´ua Lope G´omez de Marzoa s/n 15782 Santiago de Compostela, Spain E-mail: beatriz.patei[email protected] Journal of Statistical Software http://www.jstatsoft.org/ published by the American Statistical Association http://www.amstat.org/ Volume 56, Issue 4 Submitted: 2012-07-06 January 2014 Accepted: 2013-06-06