Target Outcome
- To compare two geometries and determine how consistent they are with one another. Ultimately, the end goal is to generate a colorized geometry that, based on its color, indicates to what degree the particular geometry resembles another.
Additionally, to automate geometry generation, comparison, and smoothing processing in MeshLab.
Prerequisites
Infrastructure
MeshLab. MeshLab is an open source, portable, and extensible system for the processing and editing of unstructured 3D triangular meshes (GPL license, see http://meshlab.sourceforge.net/).
Previous Protocols
For more information, see:
Comparing Two Geometries
Background: Hausdorff Distance
Hausdorff distance is defined as the "maximum distance of a set to the nearest point in another set." [Rote] This distance essentially "measures the extent to which each point of a 'model' set lies near some point of an 'image' set, and vice versa." [Huttenlocher] With that being said, the Hausdorff distance can be used to "determine the degree of resemblance when two objects are superimposed on one another." [Huttenlocher] With two geometries, the Hausdorff distance is dependent upon which geometries is selected as the target geometry and which is selected as the sampled geometry. For analysis, the following process should be done with the two geometries as both the target and sampled geometries (mesh) to ensure an accurate comparison. In other words, the process should be repeated and the geometries (meshes) should be switched.
Process
- Load both .stl geometry files into Meshlab.
Filters > Sampling > Hausdorff Distance.
- Use the default values specific to the imported geometries, as seen in the image below.
- Either can be the target or sampled mesh, but make sure to repeat and switch.
Filters > Color Creation and Processing > Colorize by Vertex Quality.
- Use the default values specific to the imported geometries, as shown in below image.
- In addition, choose the appropriate percentile crop value. If not zero this value will be used for a percentile cropping of the quality values. If this parameter is set to P the value V for which P% of the vertices have a quality lower (greater) than V is used as min (max) value. The automated percentile cropping is very useful for automatically discarding outliers.
- Min: The value that will be mapped with the lower end of the scale (blue).
- Max: The value that will be mapped with the upper end of the scale (red).
- Note that they're relative. Using two different master volumes for segmentation (cartilage versus general purpose) can skew data because general purpose has a larger image and would have error in the regions not contained in the cartilage image.
- Play with show layer dialogue in order to see just the layer (geometry/mesh) that was colorized.
- The geometry that was selected as the sampled mesh will be colored.
Render > Show Vert Quality Histogram
- For later reference, take a screenshot of the colored geometry, without a transparent background. Also, the geometry can be exported as a .ply file, retaining the vertex quality and color. Further, the log can be saved by copying the text into a .txt file. The naming convention is as followed:
For log, GeometryObject_SampledAuthorInitials_TargetAuthorInitials.txt
- Ex., FMB_CPL_CB.txt
For .ply, GeometryObject_SampledAuthorInitials_TargetAuthorInitials_PercentCrop.ply
- Ex., FMB_CPL_CB_05.ply
For snapshot, GeometryObject_SampledAuthorInitials_TargetAuthorInitials_PercentCrop.png
- Ex., FMB_CPL_CB_05.png
- Note that this naming convention is temporary and could be subject to change. Currently, the specimen number (oks00#) is not included because all results will already be under that folder.
Results
The results from the comparisons can be found within the repository at oks/oks001/dat/Geometry/Comparison Results, or by clicking on this link.
There are three folders and a readme file. The logs folder contains the logs as .txt files for each comparison. These log files were created by copy and pasting the information in the meshlab log into a .txt file. The rms values can be found here. Furthermore, the meshes folder contains the .ply files for each comparison. The snapshots folder contains screenshots for each comparison.
Examples
Comparing Identical Geometries
Below is an example of the same geometry compared with itself. Notice that there is very little, if no error present. However, when the percentile crop is changed from 0 to 5, the color scheme quickly changes. Regardless, the lack of error shows the Hausdorf Distance method is an accurate technique when measuring how identical two geometries are.
Example of Log file from Comparison:
Comparison with Percentile Crop of 0:
Comparison with Percentile Crop of 5:
Comparison with Percentile Crop of 10:
Comparing Raw versus Smooth
Below is an example of a raw tibia bone compared to the resulting smoothed version. The smoothing was done according to the guidelines outlines on the GeometryGeneration page. The example shows when smoothed bone was the sampled geometry (left) and when it was the target geometry (right).
Percentile Crop of 0:
vs.
Percentile Crop of 5:
vs.
Percentile Crop of 10:
vs.
Percentile Crop of 15:
vs.
Percentile Crop of 20:
vs.
Comparing Two Smoothed Geometries
Below is an example of a two smoothed tibia bones compared, one by the author CPL and one by the author CB. Such a comparison can show how similarly the two authors segmented the tibia. For both authors, the smoothing was done according to the guidelines outlines on the GeometryGeneration page. The example shows when CPL's smoothed tibia bone was the sampled geometry (left) and when it was the target geometry (right).
Percentile Crop of 0:
vs.
Percentile Crop of 5:
vs.
Percentile Crop of 10:
vs.
Percentile Crop of 15:
vs.
Percentile Crop of 20:
vs.
Automating Meshlab
MeshLabServer
Meshlabserver is MeshLab’s automated component. Unfortunately, there documentation on meshlabserver is limited. Meshlabserver has been incorporated into the automated smoothing and geometry comparison scripts, with the goal of minimizing time spent on repetitive processes.
Below is a screenshot image of the information provided when accessing meshlab server through the terminal.
An example using meshlabserver for geometry smoothing:
meshlabserver -i oks001_MRG_FBB_CPL_RAW_01.stl -o result2.stl -s MeshLab_FBB_Smooth_1.mlx -l log2.txt
Above, the input file is oks001_MRG_FBB_CPL_RAW_01.stl, the output file is result2.stl, the script used is MeshLab_FBB_Smooth_1.mlx, and the log is log2.txt.
Additionally, an example of using meshlabserver for geometry comparison:
meshlabserver -i oks001_MRC_TBB_LVTIT_10.stl oks001_MRC_TBB_CPL_LVTIT_01.stl -o Comparison Results/Meshes/results.ply -s MeshLab_Comparison.mlx -l log1.txt
Where oks001_MRC_TBB_LVTIT_10.stl and oks001_MRC_TBB_CPL_LVTIT_01.stl are the input files, Comparison Results/Meshes/results.ply is the output file, and the script for the process is MeshLab_Comparison.mlx. Additionally, a log of the process will be stored in log1.txt.
Creating Filter Scripts
More information to come...
oks/oks001/dat/Geometry/Scripts.pdf
For Smoothing
More information to come...
oks/oks001/dat/Geometry/Geo_Smooth.py
oks/oks001/dat/Geometry/DetermineValues.py
oks/oks001/dat/Geometry/MlxWriter.py
oks/oks001/dat/Geometry/MeshlabServerCaller.py
oks/oks001/dat/Geometry/MeshLab_FBB_Smooth_1.mlx
oks/oks001/dat/Geometry/MeshLab_FBB_Smooth_2.mlx
oks/oks001/dat/Geometry/MeshLab_PTB_Smooth.mlx
oks/oks001/dat/Geometry/MeshLab_TBB_FMB_Smooth.mlx
For Comparison
More information to come...
oks/oks001/dat/Geometry/Geo_Compare.py
oks/oks001/dat/Geometry/MeshLab_Comparison.mlx
oks/oks001/dat/Geometry/DetermineValues.py
oks/oks001/dat/Geometry/MlxWriter.py
oks/oks001/dat/Geometry/MeshlabServerCaller.py
References
Rote, G. (1991). Computing the minimum Hausdorff distance between two point sets on a line under translation. Information Processing Letters, 38(3), 123-127. doi:10.1016/0020-0190(91)90233-8
Huttenlocher, D., Klanderman, G., & Rucklidge, W. (1993, September). Comparing images using the Hausdorff distance. IEEE Transactions on Pattern Analysis and Machine Intelligence IEEE Trans. Pattern Anal. Machine Intell., 15(9), 850-863. PDF Link