Volume Cartographer 2.27.0
FlatteningError.hpp
Go to the documentation of this file.
1#pragma once
2
4#include <cstdint>
5
6#include <opencv2/core.hpp>
7
11
12namespace volcart::texturing
13{
14
26template <typename ErrContainer>
28 const cv::Mat& cellMap,
29 const ErrContainer& errorMap,
30 float defaultValue = 0)
31{
32 cv::Mat output(cellMap.rows, cellMap.cols, CV_32FC1);
33 output = cv::Scalar::all(defaultValue);
34 for (const auto& [y, x] : range2D(cellMap.rows, cellMap.cols)) {
35 auto cell = cellMap.at<std::int32_t>(y, x);
36 if (cell >= 0) {
37 auto error = errorMap.at(cell);
38 output.at<float>(y, x) = static_cast<float>(error);
39 }
40 }
41 return output;
42}
43
76 double l2{0};
78 double lInf{0};
80 std::vector<double> faceL2;
82 std::vector<double> faceLInf;
83};
84
96 const ITKMesh::Pointer& mesh3D, const ITKMesh::Pointer& mesh2D);
97
111
122std::vector<cv::Mat> PlotLStretchError(
123 const LStretchMetrics& metrics,
124 const cv::Mat& cellMap,
126 bool drawLegend = false);
127
128} // namespace volcart::texturing
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.
cv::Mat PlotPerFaceError(const cv::Mat &cellMap, const ErrContainer &errorMap, float defaultValue=0)
Plot generic per-face error information into an image.
ColorMap
Built-in color maps.
Definition: ColorMaps.hpp:17
auto range2D(T0 vStop, T1 uStop)
Definition: Iteration.hpp:341
Texturing and parameterization algorithms and utilities library.
LStretchMetrics InvertLStretchMetrics(const LStretchMetrics &metrics)
Calculates the inverse LStretchMetrics plotting error relative to the 3D mesh.
L stretch error metric output struct.
std::vector< double > faceLInf
Per-face LInf error.
std::vector< double > faceL2
Per-face L2 error.