diff --git a/Surface_mesh_segmentation/doc/Doxyfile b/Surface_mesh_segmentation/doc/Doxyfile index efce313fb8c..bda98a8eb3a 100644 --- a/Surface_mesh_segmentation/doc/Doxyfile +++ b/Surface_mesh_segmentation/doc/Doxyfile @@ -190,7 +190,7 @@ SERVER_BASED_SEARCH = NO #--------------------------------------------------------------------------- # configuration options related to the LaTeX output #--------------------------------------------------------------------------- -GENERATE_LATEX = NO +GENERATE_LATEX = YES LATEX_OUTPUT = latex LATEX_CMD_NAME = latex MAKEINDEX_CMD_NAME = makeindex diff --git a/Surface_mesh_segmentation/doc/Surface_Mesh_Segmentation.txt b/Surface_mesh_segmentation/doc/Surface_Mesh_Segmentation.txt index 1d0cf0a8d46..056dcceee5c 100644 --- a/Surface_mesh_segmentation/doc/Surface_Mesh_Segmentation.txt +++ b/Surface_mesh_segmentation/doc/Surface_Mesh_Segmentation.txt @@ -5,64 +5,83 @@ namespace CGAL { \author Ilker O. Yaz \anchor Figure-1 -\image latex elephant_sdf_partition.png "Figure 1: Elephant model with SDF values & Segmentation." width=12cm +\image latex elephant_sdf_partition.png "Elephant model with SDF values & Segmentation." width=12cm \image html elephant_sdf_partition.png "Figure 1: Elephant model with SDF values & Segmentation." # Introduction # Mesh segmentation is the process of partitioning a mesh into smaller and meaningful sub-meshes. The application domain is wide and includes, -but is not limited to modeling, rigging and texturing, shape-retrieval, and deformation. +but is not limited to modeling, rigging, texturing, shape-retrieval, and deformation. A detailed survey on mesh segmentation techniques can be found in \cite Shamir2008SegmentationSurvey. -This package provides an implementation of the algorithm presented in \cite shapira2008consistent. It relies on the Shape Diameter Function (SDF) which +This package provides an implementation of the algorithm presented in \cite Shapira2008Consistent. It relies on the Shape Diameter Function (SDF) which provides an estimate of the local volume diameter for each facet of the mesh. Given SDF values, the segmentation algorithm first applies soft clustering on facets. These clusters are then refined using a graph-cut algorithm which also considers surface-based features such as dihedral-angle and concavity. The API gives access to both the SDF computation and segmentation for a given triangulated mesh. -That way an alternative implementation of the SDF can be directly plug into the segmentation algorithm. +That way an alternative implementation of the SDF can be directly plugged into the segmentation algorithm. +Also same SDF values can be used multiple times as a parameter for the segmentation algorithm. + +Since the mesh segmentation problem is ill-posed, we also evaluate results of our implementation by using data set and evaluation software provided by \cite Chen2009SegmentationBenchmark, +and provide detailed results at the end of the manual. # Overview of the Segmentation Process # The segmentation algorithm consists of three major parts: Shape Diameter Function (SDF), soft clustering, and graph-cut for hard clustering. ## Shape Diameter Function ## The Shape Diameter Function (SDF) provides a connection between the surface and its volume. -More precisely, the SDF is a scalar-valued function defined on the surface which measures the corresponding local volume diameter. +More precisely, the SDF is a scalar-valued function defined on facets of the surface which measures the corresponding local volume diameter. The main handiness of the SDF is being able to distinguish thick and thin parts of the mesh by bringing in a volume-based feature to the surface. -Another key feature of the SDF is its pose-invariant nature, which means that SDF values remains largely unaffected after changes of pose \ref Figure-2. +Another key feature of the SDF is its pose-invariant nature, which means that SDF values remain largely unaffected after changes of pose \ref Figure-3. The SDF over a surface is computed by processing each facets one by one. For a given facet, the SDF value computation begins with casting several rays sampled from a cone which is constructed using the centroid of the facet as apex and inward-normal of the facet as axis. Using these casted rays (which intuitively correspond to a local volume sampling), -the SDF value is calculated by first applying outlier removal and then taking weighted average of ray lengths. - -After calculating SDF values for each facet, bilateral smoothing (an edge-preserving filtering technique) is applied. -The purpose of edge-preserving smoothing is removing noise while keeping fast changes on SDF values in-place without smoothing, -since they are natural candidates for segment boundaries. +the SDF value is calculated by first applying outlier removal and then taking average of ray lengths. \anchor Figure-2 -\image latex pose_changes_low.png "Figure 2: Effect of pose changes on segmentation." width=12cm -\image html pose_changes_low.png "Figure 2: Effect of pose changes on segmentation." +\image latex vogel_uniform_biased.png "Comparison of biased-to-center and uniform disk sampling for 64 rays." width=12cm +\image html vogel_uniform_biased.png "Figure 2: Comparison of biased-to-center and uniform disk sampling for 64 rays." + +We use sampling method from \cite Vogel1979Sampling to sample points from base of the cone, then combine them with apex of the cone as origin while constructing rays. +Our sampling method is biased to center in order to make sampling uniform to angle. +As a result, we do not use mentioned weighting schema in the paper in order to reduce the contributions of rays with larger angles. +A comparison with biased and uniform sampling of points can be seen in \ref Figure-2. The final SDF value of a facet is then calculated by averaging the ray lengths which fall into one Median Absolute Deviation (MAD) from the median of all lengths. + +After calculating SDF values for each facet, bilateral smoothing (an edge-preserving filtering technique) \cite Tomasi1998Bilateral is applied. +The purpose of edge-preserving smoothing is removing noise while keeping fast changes on SDF values in-place without smoothing, +since they are natural candidates for segment boundaries. +Window size \f$ w \f$, range parameter \f$ \sigma_r \f$, and spatial parameter \f$ \sigma_s \f$ are parameters for bilateral smoothing and determined as follows: +windows size is set to \f$ w = \sqrt{number\:of\:facet / 2000} + 1 \f$, +spatial parameter is half of the window size \f$ \sigma_s = w /2 \f$, +range parameter is determined for each facet by computing standard deviation of SDF values around the SDF value of current facet \f$ \sigma_{r_i} = \sqrt{1/|w_i|\sum_{f_j \in w_i}(SDF(f_j) - SDF(f_i))^2} \f$. + +\anchor Figure-3 +\image latex pose_changes_sdf_low_3.png "Effect of pose changes on segmentation and SDF values." width=12cm +\image html pose_changes_sdf_low_3.png "Figure 3: Effect of pose changes on segmentation and SDF values." ## Soft Clustering ## The soft clustering on computed SDF values first groups facets using k-means clustering algorithm which is initialized with k-means++ (an algorithm for choosing random seeds for clusters) and run multiple times. Among these runs, we choose clustering result that has minimum with-in cluster error and use it to initialize expectation maximization algorithm for fitting Gaussian mixture models. -Note that there is no direct relationship between the number of clusters (parameter for soft clustering) and the number of segments (disconnected components). +Note that there is no direct relationship between the number of clusters (parameter for soft clustering) and the number of segments (i.e. disconnected components / surface patches). Intuitively, the number of clusters represents the number of levels of a segmentation by clustering facets which have close SDF values without considering their connectivity. However, a large number of clusters is likely to result in detailed segmentation of the mesh -with a large number of segments \ref Figure-3. +with a large number of segments \ref Figure-4. The output of this step is a matrix that contains probability values for each facet to belong to each cluster. These probability values are used as input in the graph-cut step that follows. -\anchor Figure-3 -\image latex effect_of_levels.png "Figure 3: Effect of the number of clusters on the segmentation. Number of clusters were set to 4, 3, and 2 respectively." width=12cm -\image html effect_of_levels.png "Figure 3: Effect of the number of clusters on the segmentation. Number of clusters were set to 4, 3, and 2 respectively." +\anchor Figure-4 +\image latex effect_of_levels.png "Effect of different number of clusters on the segmentation. Number of clusters were set to 4, 3, and 2 respectively." width=12cm +\image html effect_of_levels.png "Figure 4: Effect of different number of clusters on the segmentation. Number of clusters were set to 4, 3, and 2 respectively." ## Graph-Cut ## The final hard clustering, which gives the final partitioning of the mesh, is obtained by minimizing an energy function. -This energy function combines the aforementioned probability matrix and geometric surface features. +This energy function combines the aforementioned probability matrix and geometric surface features. +The result of the algorithm is assigned clusters for each facet, +however we postprocess the result and produce a unique ID for each set of facets which are connected and placed under same cluster (i.e segments). -The expression of energy function that is minimized using alpha-expansion graph cut algorithm is the following: +The expression of energy function that is minimized using alpha-expansion graph cut algorithm \cite Boykov2001FastApproximate is the following: