Flattening algorithms
Coming soon.
Measuring flattening error
A common way to measure flattening error is to observe the L2 and LInf stretch metrics introduced by Sander et al. [sander2001texture] . Volume Cartographer provides a method for calculating these metrics in the Texturing module. Once calculated, these metrics can also be plotted to an image:
#include <iostream>
auto metrics =
LStretch(mesh3D, mesh2D);
std::cout << "Global L2 stretch: " << metrics.l2 << "\n";
std::cout << "Global LInf stretch: " << metrics.lInf << "\n";
std::vector< cv::Mat > PlotLStretchError(const LStretchMetrics &metrics, const cv::Mat &cellMap, ColorMap cm=ColorMap::Plasma, bool drawLegend=false)
Plot per-face L stretch error metrics.
LStretchMetrics LStretch(const ITKMesh::Pointer &mesh3D, const ITKMesh::Pointer &mesh2D)
Calculate the L2 and LInf stretch between a 2D and 3D mesh.
Texturing and parameterization algorithms and utilities library.
LStretchMetrics InvertLStretchMetrics(const LStretchMetrics &metrics)
Calculates the inverse LStretchMetrics plotting error relative to the 3D mesh.
auto GenerateCellMap(const ITKMesh::Pointer &mesh, const UVMap::Pointer &uv, std::size_t height, std::size_t width) -> cv::Mat
Generate a cell map image.
Volume Cartographer library
Flattening error can also be plotted when running vc_render
:
$ vc_render ... --uv-plot-error error_plots.png
This will generate two images, error_plots_l2.png
and error_plots_lInf.png
, plotting the per-face L2 and LInf metrics respectively.
- Note
- The L2 and LInf stretch metrics represent the stretch from the 2D domain to the 3D domain. Thus, an LInf value of 0.5 indicates a flattening where a 3D unit vector is half the length of its corresponding 2D unit vector. This is the inverse of how stretch is generally considered in most of Volume Cartographer, where we are interested in the stretch introduced relative to the 3D domain. The VC applications dealing with these metrics will often invert the returned values to make reporting more intuitive.