Volume Cartographer 2.27.0
texturing.hpp
Go to the documentation of this file.
1#pragma once
2
5#include <cstdint>
6#include <limits>
7
8#include <opencv2/core.hpp>
9#include <smgl/Node.hpp>
10
27
28namespace volcart
29{
30
37class ABFNode : public smgl::Node
38{
39private:
47 ITKMesh::Pointer mesh_{nullptr};
48
49public:
51 smgl::InputPort<ITKMesh::Pointer> input;
53 smgl::InputPort<bool> useABF;
55 smgl::OutputPort<ITKMesh::Pointer> output;
57 smgl::OutputPort<UVMap::Pointer> uvMap;
58
61
62private:
64 auto serialize_(bool useCache, const filesystem::path& cacheDir)
65 -> smgl::Metadata override;
66
69 const smgl::Metadata& meta, const filesystem::path& cacheDir) override;
70};
71
78class OrthographicFlatteningNode : public smgl::Node
79{
80private:
88 ITKMesh::Pointer mesh_{nullptr};
89
90public:
92 smgl::InputPort<ITKMesh::Pointer> input;
94 smgl::OutputPort<ITKMesh::Pointer> output;
96 smgl::OutputPort<UVMap::Pointer> uvMap;
97
100
101private:
103 auto serialize_(bool useCache, const filesystem::path& cacheDir)
104 -> smgl::Metadata override;
105
108 const smgl::Metadata& meta, const filesystem::path& cacheDir) override;
109};
110
117class FlatteningErrorNode : public smgl::Node
118{
119private:
123 ITKMesh::Pointer mesh3D_{nullptr};
125 ITKMesh::Pointer mesh2D_{nullptr};
128
129public:
131 smgl::InputPort<ITKMesh::Pointer> mesh3D;
133 smgl::InputPort<ITKMesh::Pointer> mesh2D;
135 smgl::OutputPort<Metrics> error;
136
139
140private:
142 auto serialize_(bool /*useCache*/, const filesystem::path& /*cacheDir*/)
143 -> smgl::Metadata override;
144
147 const smgl::Metadata& meta,
148 const filesystem::path& /*cacheDir*/) override;
149};
150
157class PlotLStretchErrorNode : public smgl::Node
158{
159private:
165 cv::Mat cellMap_{};
169 bool drawLegend_{false};
171 cv::Mat l2Plot_{};
173 cv::Mat lInfPlot_{};
174
175public:
177 smgl::InputPort<Metrics> error;
179 smgl::InputPort<cv::Mat> cellMap;
181 smgl::InputPort<ColorMap> colorMap;
183 smgl::InputPort<bool> drawLegend;
185 smgl::OutputPort<cv::Mat> l2Plot;
187 smgl::OutputPort<cv::Mat> lInfPlot;
188
191
192private:
194 auto serialize_(bool useCache, const filesystem::path& cacheDir)
195 -> smgl::Metadata override;
196
199 const smgl::Metadata& meta, const filesystem::path& cacheDir) override;
200};
201
208class PPMGeneratorNode : public smgl::Node
209{
210private:
219
220public:
227 smgl::InputPort<ITKMesh::Pointer> mesh;
229 smgl::InputPort<UVMap::Pointer> uvMap;
231 smgl::InputPort<Shading> shading;
233 smgl::OutputPort<PerPixelMap::Pointer> ppm;
234
237
238private:
240 auto serialize_(bool useCache, const filesystem::path& cacheDir)
241 -> smgl::Metadata override;
242
245 const smgl::Metadata& meta, const filesystem::path& cacheDir) override;
246};
247
254class CalculateNeighborhoodRadiusNode : public smgl::Node
255{
256private:
258 double thickness_{300};
260 double voxelSize_{100};
262 cv::Vec3d radius_;
263
264public:
269 smgl::InputPort<double> thickness;
271 smgl::InputPort<double> voxelSize;
273 smgl::OutputPort<cv::Vec3d> radius;
274
277
278private:
280 auto serialize_(bool /*useCache*/, const filesystem::path& /*cacheDir*/)
281 -> smgl::Metadata override;
282
285 const smgl::Metadata& meta,
286 const filesystem::path& /*cacheDir*/) override;
287};
288
294class NeighborhoodGeneratorNode : public smgl::Node
295{
296public:
298 enum class Shape {
300 Line = 0,
302 Cuboid
303 };
304
305private:
311 cv::Vec3d radius_{1, 1, 1};
313 double interval_{1};
318
319public:
321 smgl::InputPort<Shape> shape;
323 smgl::InputPort<cv::Vec3d> radius;
325 smgl::InputPort<double> interval;
330 smgl::InputPort<Direction> direction;
332 smgl::OutputPort<Generator::Pointer> generator;
333
336
337private:
339 auto serialize_(bool /*useCache*/, const filesystem::path& /*cacheDir*/)
340 -> smgl::Metadata override;
341
344 const smgl::Metadata& meta,
345 const filesystem::path& /*cacheDir*/) override;
346};
347
353class CompositeTextureNode : public smgl::Node
354{
355private:
365 cv::Mat texture_;
366
367public:
370
372 smgl::InputPort<PerPixelMap::Pointer> ppm;
374 smgl::InputPort<Volume::Pointer> volume;
376 smgl::InputPort<Generator> generator;
378 smgl::InputPort<Filter> filter;
380 smgl::OutputPort<cv::Mat> texture;
381
384
385private:
387 auto serialize_(bool useCache, const filesystem::path& cacheDir)
388 -> smgl::Metadata override;
389
392 const smgl::Metadata& meta, const filesystem::path& cacheDir) override;
393};
394
400class IntersectionTextureNode : public smgl::Node
401{
402private:
408 cv::Mat texture_;
409
410public:
412 smgl::InputPort<PerPixelMap::Pointer> ppm;
414 smgl::InputPort<Volume::Pointer> volume;
416 smgl::OutputPort<cv::Mat> texture;
417
420
421private:
423 auto serialize_(bool useCache, const filesystem::path& cacheDir)
424 -> smgl::Metadata override;
425
428 const smgl::Metadata& meta, const filesystem::path& cacheDir) override;
429};
430
436class IntegralTextureNode : public smgl::Node
437{
438private:
446 cv::Mat texture_;
447
448public:
464
466 smgl::InputPort<PerPixelMap::Pointer> ppm;
468 smgl::InputPort<Volume::Pointer> volume;
470 smgl::InputPort<Generator> generator;
472 smgl::InputPort<bool> clampValuesToMax;
474 smgl::InputPort<std::uint16_t> clampMax;
476 smgl::InputPort<WeightMethod> weightMethod;
478 smgl::InputPort<WeightDirection> linearWeightDirection;
480 smgl::InputPort<int> exponentialDiffExponent;
482 smgl::InputPort<ExpoDiffBaseMethod> exponentialDiffBaseMethod;
484 smgl::InputPort<double> exponentialDiffBaseValue;
486 smgl::InputPort<bool> exponentialDiffSuppressBelowBase;
488 smgl::OutputPort<cv::Mat> texture;
489
492
493private:
495 auto serialize_(bool useCache, const filesystem::path& cacheDir)
496 -> smgl::Metadata override;
497
500 const smgl::Metadata& meta, const filesystem::path& cacheDir) override;
501};
502
508class ThicknessTextureNode : public smgl::Node
509{
510private:
516 cv::Mat texture_;
517
518public:
520 smgl::InputPort<PerPixelMap::Pointer> ppm;
522 smgl::InputPort<Volume::Pointer> volume;
524 smgl::InputPort<VolumetricMask::Pointer> volumetricMask;
526 smgl::InputPort<double> samplingInterval;
528 smgl::InputPort<bool> normalizeOutput;
530 smgl::OutputPort<cv::Mat> texture;
531
534
535private:
537 auto serialize_(bool useCache, const filesystem::path& cacheDir)
538 -> smgl::Metadata override;
539
542 const smgl::Metadata& meta, const filesystem::path& cacheDir) override;
543};
544
550class LayerTextureNode : public smgl::Node
551{
552private:
554 using ImageList = std::vector<cv::Mat>;
563
564public:
566 smgl::InputPort<PerPixelMap::Pointer> ppm;
568 smgl::InputPort<Volume::Pointer> volume;
575 smgl::InputPort<Generator> generator;
577 smgl::OutputPort<ImageList> texture;
578
581
582private:
584 auto serialize_(bool useCache, const filesystem::path& cacheDir)
585 -> smgl::Metadata override;
586
589 const smgl::Metadata& meta, const filesystem::path& cacheDir) override;
590};
591} // namespace volcart
Parameterize a mesh using ABF++.
Definition: texturing.hpp:38
ITKMesh::Pointer mesh_
Definition: texturing.hpp:47
smgl::InputPort< bool > useABF
Whether to perform Angle-based flattening computation.
Definition: texturing.hpp:53
smgl::OutputPort< ITKMesh::Pointer > output
Flattened mesh.
Definition: texturing.hpp:55
void deserialize_(const smgl::Metadata &meta, const filesystem::path &cacheDir) override
smgl::InputPort< ITKMesh::Pointer > input
Input mesh.
Definition: texturing.hpp:51
UVMap::Pointer uvMap_
Definition: texturing.hpp:45
auto serialize_(bool useCache, const filesystem::path &cacheDir) -> smgl::Metadata override
smgl::OutputPort< UVMap::Pointer > uvMap
UVMap generated from flattened mesh.
Definition: texturing.hpp:57
Auto-calculate a texturing neighborhood's 3D radius in voxels given the expected layer thickness and ...
Definition: texturing.hpp:255
smgl::OutputPort< cv::Vec3d > radius
3D neighborhood radius
Definition: texturing.hpp:273
smgl::InputPort< double > voxelSize
Texturing Volume voxel size (um)
Definition: texturing.hpp:271
auto serialize_(bool, const filesystem::path &) -> smgl::Metadata override
smgl::InputPort< double > thickness
Estimated layer thickness (um)
Definition: texturing.hpp:269
void deserialize_(const smgl::Metadata &meta, const filesystem::path &) override
Generate a texture image using a variety of composite volume filters.
Definition: texturing.hpp:354
auto serialize_(bool useCache, const filesystem::path &cacheDir) -> smgl::Metadata override
void deserialize_(const smgl::Metadata &meta, const filesystem::path &cacheDir) override
smgl::OutputPort< cv::Mat > texture
Generated texture image.
Definition: texturing.hpp:380
smgl::InputPort< Generator > generator
Neighborhood generator.
Definition: texturing.hpp:376
smgl::InputPort< Volume::Pointer > volume
Input Volume.
Definition: texturing.hpp:374
NeighborhoodGenerator::Pointer Generator
Definition: texturing.hpp:359
smgl::InputPort< PerPixelMap::Pointer > ppm
Input PerPixelMap.
Definition: texturing.hpp:372
smgl::InputPort< Filter > filter
Composite filter type.
Definition: texturing.hpp:378
Calculate the L2 and LInf stretch between a 2D and 3D mesh.
Definition: texturing.hpp:118
void deserialize_(const smgl::Metadata &meta, const filesystem::path &) override
smgl::InputPort< ITKMesh::Pointer > mesh3D
Input mesh (3D)
Definition: texturing.hpp:131
auto serialize_(bool, const filesystem::path &) -> smgl::Metadata override
smgl::InputPort< ITKMesh::Pointer > mesh2D
Input mesh (2D)
Definition: texturing.hpp:133
smgl::OutputPort< Metrics > error
Calculated error metrics.
Definition: texturing.hpp:135
ITKMesh::Pointer mesh2D_
Definition: texturing.hpp:125
ITKMesh::Pointer mesh3D_
Definition: texturing.hpp:123
Generate a Texture by taking the discrete integral (summation) of the neighborhood adjacent to a poin...
Definition: texturing.hpp:437
smgl::OutputPort< cv::Mat > texture
Generated texture image.
Definition: texturing.hpp:488
void deserialize_(const smgl::Metadata &meta, const filesystem::path &cacheDir) override
smgl::InputPort< std::uint16_t > clampMax
The maximum intensity value allowed in neighborhood prior to integration.
Definition: texturing.hpp:474
smgl::InputPort< bool > clampValuesToMax
When enabled, clamp neighborhood intensities to the value specified by setClampMax()
Definition: texturing.hpp:472
smgl::InputPort< int > exponentialDiffExponent
Set the weighting exponent used by Exponential Difference weighting.
Definition: texturing.hpp:480
smgl::InputPort< double > exponentialDiffBaseValue
Set the base value for Exponential Difference weighting.
Definition: texturing.hpp:484
smgl::InputPort< Generator > generator
Neighborhood generator.
Definition: texturing.hpp:470
smgl::InputPort< bool > exponentialDiffSuppressBelowBase
When enabled, do not integrate intensity values below the base value.
Definition: texturing.hpp:486
smgl::InputPort< PerPixelMap::Pointer > ppm
Input PerPixelMap.
Definition: texturing.hpp:466
auto serialize_(bool useCache, const filesystem::path &cacheDir) -> smgl::Metadata override
smgl::InputPort< Volume::Pointer > volume
Input Volume.
Definition: texturing.hpp:468
smgl::InputPort< ExpoDiffBaseMethod > exponentialDiffBaseMethod
Set the method used to calculate the Exponential Difference base value.
Definition: texturing.hpp:482
smgl::InputPort< WeightMethod > weightMethod
Set the weighting method.
Definition: texturing.hpp:476
smgl::InputPort< WeightDirection > linearWeightDirection
Set the linear weight direction.
Definition: texturing.hpp:478
NeighborhoodGenerator::Pointer Generator
Definition: texturing.hpp:442
Generate a Texture by intersection with a Volume.
Definition: texturing.hpp:401
smgl::InputPort< Volume::Pointer > volume
Input Volume.
Definition: texturing.hpp:414
smgl::InputPort< PerPixelMap::Pointer > ppm
Input PerPixelMap.
Definition: texturing.hpp:412
void deserialize_(const smgl::Metadata &meta, const filesystem::path &cacheDir) override
smgl::OutputPort< cv::Mat > texture
Generated texture image.
Definition: texturing.hpp:416
auto serialize_(bool useCache, const filesystem::path &cacheDir) -> smgl::Metadata override
Generate a Texture of layered images.
Definition: texturing.hpp:551
NeighborhoodGenerator::Pointer Generator
Definition: texturing.hpp:558
smgl::InputPort< PerPixelMap::Pointer > ppm
Input PerPixelMap.
Definition: texturing.hpp:566
smgl::InputPort< Volume::Pointer > volume
Input Volume.
Definition: texturing.hpp:568
smgl::InputPort< Generator > generator
Neighborhood generator.
Definition: texturing.hpp:575
std::vector< cv::Mat > ImageList
Definition: texturing.hpp:554
void deserialize_(const smgl::Metadata &meta, const filesystem::path &cacheDir) override
auto serialize_(bool useCache, const filesystem::path &cacheDir) -> smgl::Metadata override
smgl::OutputPort< ImageList > texture
Generated texture image.
Definition: texturing.hpp:577
Configure a NeighborhoodGenerator for use by a texturing algorithm.
Definition: texturing.hpp:295
smgl::OutputPort< Generator::Pointer > generator
Configured neighborhood generator.
Definition: texturing.hpp:332
smgl::InputPort< Shape > shape
Neighborhood shape.
Definition: texturing.hpp:321
void deserialize_(const smgl::Metadata &meta, const filesystem::path &) override
smgl::InputPort< Direction > direction
Sampling direction.
Definition: texturing.hpp:330
auto serialize_(bool, const filesystem::path &) -> smgl::Metadata override
smgl::InputPort< double > interval
Sampling rate along the radius.
Definition: texturing.hpp:325
smgl::InputPort< cv::Vec3d > radius
3D neighborhood radius
Definition: texturing.hpp:323
Base class for neighborhood generating classes.
std::shared_ptr< NeighborhoodGenerator > Pointer
Computes a 2D parameterization of a triangular mesh using orthographic projection.
Definition: texturing.hpp:79
void deserialize_(const smgl::Metadata &meta, const filesystem::path &cacheDir) override
smgl::InputPort< ITKMesh::Pointer > input
Input mesh.
Definition: texturing.hpp:92
smgl::OutputPort< ITKMesh::Pointer > output
Flattened mesh.
Definition: texturing.hpp:94
smgl::OutputPort< UVMap::Pointer > uvMap
UVMap generated from flattened mesh.
Definition: texturing.hpp:96
auto serialize_(bool useCache, const filesystem::path &cacheDir) -> smgl::Metadata override
Generates a PerPixelMap from an ITKMesh and a UVMap.
Definition: texturing.hpp:209
smgl::OutputPort< PerPixelMap::Pointer > ppm
Output PerPixelMap.
Definition: texturing.hpp:233
smgl::InputPort< ITKMesh::Pointer > mesh
Input mesh.
Definition: texturing.hpp:227
auto serialize_(bool useCache, const filesystem::path &cacheDir) -> smgl::Metadata override
PerPixelMap::Pointer ppm_
Definition: texturing.hpp:218
PPMGen::Shading shading_
Definition: texturing.hpp:216
smgl::InputPort< UVMap::Pointer > uvMap
Input UVMap.
Definition: texturing.hpp:229
smgl::InputPort< Shading > shading
Pixel normal shading method.
Definition: texturing.hpp:231
void deserialize_(const smgl::Metadata &meta, const filesystem::path &cacheDir) override
std::shared_ptr< PerPixelMap > Pointer
Definition: PerPixelMap.hpp:84
Plot per-face L stretch error metrics.
Definition: texturing.hpp:158
auto serialize_(bool useCache, const filesystem::path &cacheDir) -> smgl::Metadata override
smgl::InputPort< Metrics > error
Input error metrics.
Definition: texturing.hpp:177
smgl::InputPort< ColorMap > colorMap
Color map/LUT for visualization.
Definition: texturing.hpp:181
smgl::OutputPort< cv::Mat > lInfPlot
LInf error image.
Definition: texturing.hpp:187
smgl::InputPort< bool > drawLegend
Whether to add a legend to the image.
Definition: texturing.hpp:183
void deserialize_(const smgl::Metadata &meta, const filesystem::path &cacheDir) override
smgl::InputPort< cv::Mat > cellMap
Per-pixel mesh cell assignment, generally from a PerPixelMap.
Definition: texturing.hpp:179
smgl::OutputPort< cv::Mat > l2Plot
L2 error image.
Definition: texturing.hpp:185
Generate a Texture using the thickness of the segmented layer.
Definition: texturing.hpp:509
smgl::InputPort< double > samplingInterval
Set the sampling interval.
Definition: texturing.hpp:526
smgl::InputPort< VolumetricMask::Pointer > volumetricMask
VolumetricMask for a single layer.
Definition: texturing.hpp:524
void deserialize_(const smgl::Metadata &meta, const filesystem::path &cacheDir) override
smgl::InputPort< bool > normalizeOutput
Normalize the output image.
Definition: texturing.hpp:528
auto serialize_(bool useCache, const filesystem::path &cacheDir) -> smgl::Metadata override
smgl::InputPort< Volume::Pointer > volume
Input Volume.
Definition: texturing.hpp:522
smgl::InputPort< PerPixelMap::Pointer > ppm
Input PerPixelMap.
Definition: texturing.hpp:520
smgl::OutputPort< cv::Mat > texture
Generated texture image.
Definition: texturing.hpp:530
std::shared_ptr< UVMap > Pointer
Definition: UVMap.hpp:55
Generate a texture image using a variety of composite volume filters.
@ Maximum
Select the maximum intensity value.
Generate a Texture by taking the discrete integral (summation) of the neighborhood adjacent to a poin...
ExpoDiffBaseMethod
Exponential difference base calculation method.
LinearWeightDirection
Linear weight direction.
Generate a Texture by intersection with a Volume.
Generate a Texture of layered images.
Computes a 2D parameterization of a triangular mesh using orthographic projection.
Generates a PerPixelMap from an ITKMesh and a UVMap.
Shading
Pixel normal shading method.
@ Smooth
Each pixel's normal is a linear interpolation of the face's vertex normals. This is similar to Phong ...
Generate a Texture using the thickness of the segmented layer.
ColorMap
Built-in color maps.
Definition: ColorMaps.hpp:17
Volume Cartographer library
Direction
Neighborhood directional filtering options.
@ Bidirectional
Consider data in both the positive and negative normal.
L stretch error metric output struct.