Surface Reconstruction from a Point Cloud with Normals Landon Boyd and Massih Khorvash Department of Computer Science University of British Columbia,2366 Main Mall Vancouver, BC, V6T1Z4, Canada {blandon,khorvash}@cs.ubc.ca Abstract We set out to implement a tool to reconstruct a 3-D triangle mesh from a set of points and the corresponding normals of an unknown surface. This surface may have arbitrarily complex topology and geometry, and may contain boundaries. We base our implementation on an influential reconstruction paper [HDD 92]. Results were generated for a variety of challenging inputs. 1. Introduction Hoppe et al. [HDD 92] describe an algorithm to reconstruct simplicial surfaces from a set of points, as one would expect from the output of a laser range scanner. Although the use of Marching Cubes [LC87] for surface reconstruction was not new, their work was groundbreaking in its handling of arbitrary topology and boundaries. As such, the work has been cited by a vast number of surface reconstruction papers (1465 citations on Google Scholar as of Dec. 10, 2008). We chose to implement this algorithm as we believed it would give us insight into the core ideas underlying many state-of-the-art surface reconstruction techniques. Taking a set of points on the unknown surface with their normals allowed us to simplify the algorithm. The rest of this report is organized as follows. Section 2 describes the algorithm. In section 3, we describe how we implemented the algorithm. Section 4 shows the results obtained. In section 5 we draw conclusions and suggest some possible improvements. 2. Algorithm Hoppe et al. s algorithm has two phases and a refinement step as follows. Phase 1: Calculate a tangent plane for each sample point Determine a globally consistent orientation for the normals of the tangent planes Phase 2: Extract an isosurface using Marching Cubes [LC87] with the signed distance function Refinement step: Improve the quality of the resulting mesh by collapsing edges of triangles with undesirable aspect ratios For this project, we are given the normals at each of the input points, which makes the first phase unnecessary. The signed distance function is as shown in algorithm 1. In other words, the distance function returns the distance of each marching cube vertex to the tangent plane of the nearest sample point, with the following exception: if the projected point, z, is too far away from any sample points (given the sampling density), the distance function returns undefined. When a marching cube has an undefined value at any of its vertices, no surface is generated within that cube. That way, the algorithm can reconstruct surfaces with boundaries. 2.1. Algorithm Complexity The subproblems of extracting the isosurface by marching cubes are:
2 Input: A marching cube vertex p, Sampling density ρ SIGNED-DISTANCE-FUNCTION(p, ρ): begin o the nearest sample point to p ˆn the normal at o z the projection of p onto the tangent plane defined by o and ˆn d the distance to the sample point nearest to z if d < ρ then return (p o) ˆn else return undefined Algorithm 1: Definition of the signed distance function Determining the nearest sample input point to each marching cube vertex, p. Determining the nearest sample input point to each projected marching cube vertex, z. Both steps require finding the nearest sample in the point cloud to a given point. By using a k-d tree [Ben80], the resultant time complexity is O(log(n)), where n is the number of points in the cloud. Hence, the time complexity of our algorithm is O(mlog(n)), where m is the number of marching cubes. The empirical results are shown in section 4. 3. Implementation Implementation was divided into following subtasks. Generate point and normal data Read points and normals into a data structure Implement the signed distance function Integrate contour tracing using marching cubes Post-process to eliminate undesirable triangles For input data, we used freely available 3-D models from various sources. We implemented a tool in Graphite which extracted the vertices and their normals from a model and wrote them to a file with a.cloud extension. We exted Graphite to read these.cloud files containing point and normal data, by implementing a PointCloud class exting OGF::Grob ( GRaphite OBject ). This way, from the user s point of view, loading point cloud is as easy as loading any other type of file. When the user selects a.cloud file, a PointCloud object is created and its load() member function is called to parse the data. Because the signed distance function requires finding the nearest neighbor amongst points in the cloud, it was important that the points be stored in a data structure allowing this for instance, http://shapes.aim-at-shape.net/index.php search to be performed efficiently. We used the k-d tree implementation, libkdtree++, by Martin F. Krafft. Due to its effective use of C++ templates, we did not have to change a line of code in that library; we only had to implement a trivial functor class to allow comparison between the PointNormal objects stored in the structure. The biggest decision regarding the signed distance function was determination of ρ, the sampling density. In a real world scenario, this would be a property of the range scanner. By default, we used the maximum distance between any point and its nearest neighbor, as anything less could result in extraneous boundaries. We provided a user interface to allow the default to be overridden and also provided an option to help the user choose ρ by presenting a histogram of the nearest neighbor distances for all sample points. For contour tracing, we started with the MarchingCubes class by Josh Grant. It was implemented for the Open Inventor environment, so we first updated the code to work with Graphite by removing any Open Inventor specific code, defining a ScalarField class and using OGF::Vector3d instead of the Open Inventor equivalent. We also updated MarchingCubes to take a ScalarField of pairs, the first element of the pair containing the value of the distance function (at a marching cube vertex) and the second element, a boolean indicating whether the value is defined in the sense described in section 2. Additional logic was added to avoid generating triangles for cubes with undefined values for any of their vertices, thus allowing the reconstruction of boundaries. When we ran marching cubes against a model of Homer, the resulting mesh was shorter and fatter than the input. This was because MarchingCubes always made its grid fit exactly within a 1 1 1 bounding box, even if there were an unequal number of cubes along the three axes. We updated MarchingCubes to always use grid cells of equal length on all sides (i.e. cubes ), with only the cubes along the longest axis adding up to 1 unit length. The final step was to post-process the reconstructed mesh to remove unsightly triangles generated by marching cubes. We used a mesh simplifier based on the quadric error metric [GH97] and let the user decide how much simplification results in acceptable mesh quality. 4. Results We were impressed by the results. Our algorithm did reconstruct models with complex topology and geometry, and also reconstructed boundaries. When it was faced with inadequate data, it still produced a plausible mesh. http://libkdtree.alioth.debian.org/ http://www.wheatchex.com/projects/mcubes/ implemented for assignment 2
3 To test the ability of our algorithm to reconstruct a basic surface with a boundary, we tried it on an ellipsoid cloud consisting of 3387 points, with a hole cut out of one (figure 1). from a 40,000 vertex chair model. This was a challenging model to reproduce for a number of reasons. In addition to the high genus, it also has relatively fine detail in the form of thin rods that make up its back and legs and a thin, flat seat. The original mesh and resulting reconstruction are shown in figure 4. Figure 1: ellipsoid point cloud with normals in green The boundary of the original ellipsoid model was reconstructed as shown in figure 2. Figure 4: original chair model (left) and reconstruction (right) Figure 2: original ellipsoid mesh (left) and generated mesh (right) To see how the boundary was reproduced, it s instructive to look at the marching cube values. In figure 3, we show the marching cube vertices with values less than 0 (yellow) and vertices with undefined values (pink). In the area of the hole, the signed distance function produces undefined values, which prevents a surface from being generated in those cubes, resulting in the desired boundary. The resulting mesh has no boundaries and reproduces the original shape well, though some additional holes are introduced in the seat. Some stair step artifacts can also be seen on parts of the seat back. We believe the reason for the holes in the seat is a more pronounced stair stepping effect, because of the angle of the seat in relation to the marching cubes (figure 5). Figure 3: inside and undefined marching cube vertices To test complex topology, we used a point cloud generated Figure 5: chair orientation, close up of stair step effect on seat
4 A geometrically complex knot was handled particularly well, as shown in figure 6. Figure 6: knot point cloud (left) and reconstruction (right) The Homer point cloud had a few undersampled regions which revealed themselves after we added boundary reproduction to our code. figure 7 shows the output mesh with boundaries. Figure 8: Marching cube projections of Homer not practical in the case of Homer. Another option is to disable boundary detection. By choosing this option in the user interface, the mesh is generated which captures all of the detail but does not have boundaries. This is an acceptable solution for Homer because there are no boundaries desired in the surface. However, this may not always be the case. The best option, when possible, would be to fill in the undersampled region with reasonable sample points. Figure 7: Homer with boundaries As expected, the mesh quality produced by marching cubes is less than ideal. As shown with the bunny model in figure 9, there are noticeable artifacts, seen as contours of the distance function. Hoppe et al. suggest collapsing edges using a priority queue sorted by the aspect ratio of triangles. We obtained good results by collapsing edges according to the quadric error metric [GH97]. In figure 9, we also show the result of simplification to various mesh sizes and clearly the artifacts are eliminated without much detriment to the level of detail in the mesh. We are able to visualize the undersampling in the point cloud by viewing the projections of certain marching cube vertices onto the tangent planes of their nearest points (figure 8). It can be seen that the projected points (z in the algorithm) are far away from any sample points, resulting in the boundary. When faced with this situation, the user has a few options. One is to reduce the specified sampling density; this makes the algorithm more tolerant to undersampling, but also results in less detail in the resultant surface. This was http://www.knotplot.com/zoo/ Figure 9: generated bunny mesh (7k vertices, left), simplified to 6k (middle) and 5k (right) To evaluate the performance of our implementation, we reconstructed the hand point cloud in figure 10 consisting of 53054 points.
5 Figure 10: hand point cloud (left), marching cubes (middle) and reconstructed surface (right) [KBSS01] KOBBELT L. P., BOTSCH M., SCHWANECKE U., SEIDEL H.-P.: Feature sensitive surface extraction from volume data. In SIGGRAPH 01: Proceedings of the 28th annual conference on Computer graphics and interactive techniques (New York, NY, USA, 2001), ACM, pp. 57 66. [LC87] LORENSEN W. E., CLINE H. E.: Marching cubes: A high resolution 3d surface construction algorithm. SIG- GRAPH Comput. Graph. 21, 4 (1987), 163 169. On a 3.2GHz Pentium 4, reconstruction of the 40,000 vertex output model took 33 minutes. 5. Conclusion We implemented a variant of a fundamental reconstruction algorithm by Hoppe et al., which is the basis of many other reconstruction algorithms. We tested our implementation on several geometrically and topologically complex models, and also some models with boundaries. Rather than using only an unorganized point cloud, we used a cloud of points with their normals. We also assumed noiseless data. Our algorithm reconstructed impressive results in a reasonable time, the most noticeable limitation being stair step artifacts on thin features not aligned with the marching cube grid. The performance could be improved by only considering cubes in the region of the surface, using a technique such as adaptive octree refinement [KBSS01]. Also, it might be possible to improve performance by using marching cubes larger than the sampling density. References [Ben80] BENTLEY J. L.: Multidimensional divide-andconquer. Commun. ACM 23, 4 (1980), 214 229. [GH97] GARLAND M., HECKBERT P. S.: Surface simplification using quadric error metrics. In SIGGRAPH 97: Proceedings of the 24th annual conference on Computer graphics and interactive techniques (New York, NY, USA, 1997), ACM Press/Addison-Wesley Publishing Co., pp. 209 216. [HDD 92] HOPPE H., DEROSE T., DUCHAMP T., MC- DONALD J., STUETZLE W.: Surface reconstruction from unorganized points. In SIGGRAPH 92: Proceedings of the 19th annual conference on Computer graphics and interactive techniques (New York, NY, USA, 1992), ACM, pp. 71 78.