NURBS Parameterization for Medical Surface Reconstruction

InVesalius is an open-source software for reconstruction of computed tomography and magnetic resonance images, which allows the user to make analysis and segmentation of virtual anatomical models. Physical models can be printed with the aid of rapid prototyping, giving the medical community a reliable instrument to help planning surgeries. To offer the user more control over the model, this work describes a methodology and tool developed for NURBS parameterization that provides mechanisms for adjusting the shape or even selecting a particular region of interest of the surface. Furthermore, the tool gives the option to export the final results of the process to a STEP file, which allows further edition in any well-known CAD software.


Introduction
Virtual modeling offers the clinical community the possibility to visualize the interior of the human body in a non-invasive way, allowing a more precise diagnosis of the patient.Thus, it has become an important tool for surgical planning, reducing costs and medical errors.
In order to generate an accurate model of the anatomical region to be studied, it is necessary to be able to work on medical images obtained from either computed tomography or magnetic resonance, such that one can correct many aspects susceptible to occur during acquisition (e.g., equipment out of calibration or image artifacts caused by noise), reconstruct and model the tridimensional surface by stacking bidimensional images, segment the surface into regions of interest, and acquire anatomical measurements, among other possible tasks.
In this context, the open-source software InVesalius [1] is a proper option to help in this entire process through its edition tools.InVesalius is a free software under GNU General Public License, allowing researchers and developers from universities and research centers from all over the world to contribute with the improvement of it.Until now, more than 10,000 people from 127 countries are active users of the software.Written mainly in Python programming language, the input data to InVesalius consist of medical image files, either in Digital Imaging and Communications in Medicine (DICOM) or in Analyze file formats, originated from computed tomography and magnetic resonance imaging.Many libraries are also implemented to give support to the features offered by the software, such as wxPython for the graphical interface and Visualization Toolkit (VTK) [2] for 2D and 3D visualization of the images and surfaces.
Several features are offered to the users of InVesalius.The highlights among them include image segmentation, where the user can automatically segment an image by a threshold value and then refine the results manually; 3D surface reconstruction through the Marching Cubes algorithm [3]; volumetric visualization generated by Ray Casting technique [4]; and measurements, both linear and angular, on the 2D slices and 3D surfaces.Figure 1 illustrates these main features of InVesalius tool (respectively, top left, top right, second row and third row).
These features allow the user to make analysis of virtual anatomical models, from which physical models can be printed with the aid of rapid prototyping, giving the medical community a reliable instrument to help planning surgeries.In order to offer the user more control over the model to be printed, the new feature described in this paper and available in a future version of InVesalius extracts the point cloud of the input surface, reconstructs it through NURBS parameterization [5] [6] and exports the results to a STEP file, allowing further edition through any Computer Aided Design (CAD) software.
NURBS is an acronym to Non-Uniform Rational B-Splines and was introduced to the Computer Graphics community after studies of several works on the physical properties of piecewise polynomials known as splines [7].As an extension of B-splines, NURBS functions share many of their relevant properties, mainly the 2 C continuity and local support ones, permitting the former a smoother representation of curves and surfaces and the latter, more control over changes on the forms resulting from alterations on the parameters values.
Parameterization by means of NURBS functions allows one to obtain a flexible and versatile modeling of curves and surfaces, being capable, therefore, to represent either simple curves and surfaces, as conics, or those more complex, such as free-form ones.Once modeled by NURBS, the curve or surface offers a malleability in the representation of its form via the rearrangement of the control points or reassignment of the weight values.As a consequence, NURBS became the standard functions for description of curves and surfaces in Computer Science and Engineering [6].
The remainder of the paper is organized as follows.Section 2 goes into some mathematical foundations of B-splines and NURBS functions; an extensive study can be found in the book by Piegl et al. [6] and references therein.Section 3 briefly describes the STEP file format.Section 4 presents the methodology behind the tool.Section 5 discusses the results obtained with the proposed methodology.Section 6 concludes the paper with final remarks and directions for future work.

B-Splines and NURBS Functions
For a set { } i P of ( ) control points on the plane, with 0 i p ≤ ≤ , a B-spline curve of order 1 k + (or, equivalently, of degree k) is given by the formula where 0 1 u ≤ ≤ (i.e., u is a normalized parameter) and ( ) N u is the i-th basis function of the B-spline, which is defined on a non-decreasing sequence of real numbers , and calculated according to  1), moving the former only affects the curve shape on the subintervals where the latter is nonzero.Thus, knot values establish to what extent the control points affect the shape of the curve.
A B-spline surface of order ( )( ) given a bidirectional net of ( )( )

P
in the tridimensional space, with 0 i p ≤ ≤ and 0 j q ≤ ≤ , two knot vectors , , , , , , , , , and corresponding basis functions ( ) NURBS curves and surfaces [7] [8] are generalizations of B-splines curves and surfaces.By introducing weights to the control points, a intrinsically non-rational B-spline becomes rational and provides a way of adjusting the shape of the form without adding excessively new control points.Equations ( 1) and (3) change into ( ) , respectively, where { } i w and { } , i j w are the weights to the control points in each equation.Therefore, after reconstructing the surface as a NURBS one, the user is able to modify the shape of it to meet his needs, just altering the positions or weights of the control points.Furthermore, the local support property inherited from the B-splines ensures that any change to those parameters affects only a local region of the surface, and not the whole of it, giving the user more control over the adjustment of his region of interest.

STEP Files
STEP [9] is an International Organization for Standardization (ISO) standard whose acronym stands for Standard for the Exchange of Product Model Data.Informally, the successor of Initial Graphics Exchange Specification (IGES) file created by the United States Air Force Integrated Computer Aided Manufacturing project, STEP file was developed to be a universal and implementation-independent representation and exchange of product manufacturing information.
Among the several STEP application protocols that exist, the most widely known and used is AP203 (Configuration Controlled Design) [10], which represents 3D objects that can be imported and exported by many CAD systems.Since one of the goals of our work was to allow the user to reopen the surface generated by InVesalius in any CAD software, AP203 was chosen as the file type to export the reconstruction results.

Methodology
All the NURBS surface reconstruction modules implemented in the methodology were developed in C++ programming language using libraries provided by the Point Cloud Library (PCL) project [11], which contains several open source algorithms for image and point cloud processing and is developed by scientists from many organizations worldwide distributed.
Primarily, the algorithm accepts, as inputs, point clouds stored in Polygon File Format (PLY) or StereoLithography (STL) file types, the first for being most commonly used to store tridimensional data obtained from 3D scanners, the second because of its widely usage for rapid prototyping and 3D printing, and both for being sup-ported by almost every software package known nowadays, including InVesalius.After reading the input file, the algorithm extracts the data and opens a visualization window with the point cloud that was read.
Once the visualization window is open with the input, the NURBS reconstruction can be executed to the entire surface or to a specific point set.In the latter case, a keyboard shortcut activates the selection cursor, allowing the user to draw a rectangle over the region of interest.Done this procedure, the script changes the content of the visualization window to show the set of points selected.In case the result is not as expected, the user can switch back to the original point cloud and make a new selection.Being the as anticipated, the algorithm saves it to an output file with the same format of the input.
The reconstruction step, either executed on the entire point cloud or on the selected region, is automatic.This process starts with an initial NURBS surface, constructed using Principal Component Analysis (PCA) [12].A new coordinate system, centered at the mean of the points of the cloud to be reconstructed, is created from the main eigenvectors obtained by PCA, pointing them into the directions of the maximum, middle and minimum extension of the point cloud.Also, a bounding box is estimated in the plane comprised by the maximum and middle eigenvectors and used to determine the extension of the NURBS domain.With all this, the NURBS surface is initialized with a minimal number of control points, according to the degree specified.
To improve the quality of the surface, refinements procedures are iteratively executed on it.The strategy behind them is to add more control points to the initial surface by knot insertion, in order to increase flexibility in shape control.This can be done because, in any direction of the surface, the number of control points CP is tied to the number of knots K by the relation where D is the degree of the NURBS surface in the respective direction [6].So, in each iteration of the refinement, a knot is inserted in the middle of each knot direction and the NURBS surface with this new configuration is fitted to the point cloud, by minimizing, using least squares minimization, the system of equations derived from the difference between each point in the cloud and its associated point on the NURBS surface.This process is repeated until a preset number of iterations is reached.
In the end, the surface reconstructed is displayed on the visualization window, giving the user the option to export the final result to a STEP file, which procedure is implemented using open source libraries from Open CASCADE Technology [13].In this case, the NURBS parameters (knots and degrees in both directions, control points grid and weight values) are extracted from the PCL structures where they were stored after the reconstruction was done and exported to the structures provided and used by Open CASCADE.Once this conversion is concluded, all the data regarding the NURBS surface reconstructed is transcribed to a STEP file as the final output of the methodology.
Therefore, after reconstructing the surface as a NURBS one, the user is able to modify the shape of it to meet his needs, just altering the positions or weights of the control points.Furthermore, the local support property inherited from the B-splines ensures that any change to those parameters affects only a local region of the surface, and not the whole of it, giving the user more control over the adjustment of his region of interest.The selection process on the input data, aiming the reconstruction of a specific region of interest, can be seen in Figure 3, where each row represents a particular selection.The first row illustrates the selection of points belonging to the eye band; the second row, of points centered on the nose; and the third row, of points from the bottom of the face, embodying both mouth and chin.

Results
Regarding the reconstruction step, Figure 4 and Figure 5 present the NURBS surfaces reconstructed with the methodology by using libraries from PCL specific to that.The former shows the reconstruction of the whole surface of the face obtained from the input data, whereas the latter corresponds to the selections performed and reproduced in Figure 3.In both of them, from left to right, the resulting surface is visualized as the outcome of the methodology and by Rhinoceros software [14], in this case showing the control points grid.It is relevant to notice the quality of the reconstruction, considering the complexity of a real human face as the input data.

Conclusions and Future Work
This paper presented a new methodology for surface reconstruction through NURBS parameterization developed to be included in a coming version of InVesalius software.The methodology extracts a point cloud stored in PLY or STL files and reconstructs a NURBS surface from the entire data set or from a specific region of interest, exporting the result to a STEP file, such that the user is able to reopen and edit the surface reconstructed in any CAD software.
As seen in Figure 4 and Figure 5, the borders of the NURBS surfaces extrapolate those of the point clouds.Therefore, as future work, we intend to improve the algorithm behind the methodology, so both borders coincide or, at least, are as close as possible, thus enhancing the verisimilitude between the reconstructions and the original data.
Another direction for future work is to apply the developed methodology to the face recognition problem.2D face recognition is a widely investigated topic, in contraposition to the ones that deal with 3D images.Furthermore, the tridimensional case, through surface shape and texture information simultaneously during the procedure, avoids recognition problems inherent to the bidimensional one, such as those resulting from illumination or face pose changes [15].Therefore, we plan to employ surfaces reconstructed via NURBS parameterization on tridimensional face recognition processes using the control points net as a unique descriptor for each face.

Figure 1 .
Figure 1.Some InVesalius features.From Equation (2), it is straightforward to see that the basis function

Figure 2
Figure 2 illustrates an example of input data, obtained from a PLY file, where the original point cloud (left) and its corresponding visualization window generated by the algorithm (right) are shown.The cloud depicts a human face containing 35,404 points and 70,106 faces, which was used for testing purposes during the development to assert the correctness of the methodology.The selection process on the input data, aiming the reconstruction of a specific region of interest, can be seen in Figure3, where each row represents a particular selection.The first row illustrates the selection of points belonging to the eye band; the second row, of points centered on the nose; and the third row, of points from the bottom of the face, embodying both mouth and chin.Regarding the reconstruction step, Figure4and Figure5present the NURBS surfaces reconstructed with the methodology by using libraries from PCL specific to that.The former shows the reconstruction of the whole surface of the face obtained from the input data, whereas the latter corresponds to the selections performed and reproduced in Figure3.In both of them, from left to right, the resulting surface is visualized as the outcome of the methodology and by Rhinoceros software[14], in this case showing the control points grid.It is relevant to notice the quality of the reconstruction, considering the complexity of a real human face as the input data.

Figure 2 .
Figure 2. Input data and visualization window.