Volume Cartographer 2.28.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{
46 ITKMesh::Pointer mesh_{nullptr};
47
48public:
50 smgl::InputPort<ITKMesh::Pointer> input;
52 smgl::InputPort<bool> useABF;
54 smgl::InputPort<bool> useHLSCM;
56 smgl::InputPort<ABF::Solver> solver;
58 smgl::OutputPort<ITKMesh::Pointer> output;
60 smgl::OutputPort<UVMap::Pointer> uvMap;
61
64
65private:
67 auto serialize_(bool useCache, const filesystem::path& cacheDir)
68 -> smgl::Metadata override;
69
72 const smgl::Metadata& meta, const filesystem::path& cacheDir) override;
73};
74
81class OrthographicFlatteningNode : public smgl::Node
82{
83private:
91 ITKMesh::Pointer mesh_{nullptr};
92
93public:
95 smgl::InputPort<ITKMesh::Pointer> input;
97 smgl::OutputPort<ITKMesh::Pointer> output;
99 smgl::OutputPort<UVMap::Pointer> uvMap;
100
103
104private:
106 auto serialize_(bool useCache, const filesystem::path& cacheDir)
107 -> smgl::Metadata override;
108
111 const smgl::Metadata& meta, const filesystem::path& cacheDir) override;
112};
113
120class FlatteningErrorNode : public smgl::Node
121{
122private:
126 ITKMesh::Pointer mesh3D_{nullptr};
128 ITKMesh::Pointer mesh2D_{nullptr};
131
132public:
134 smgl::InputPort<ITKMesh::Pointer> mesh3D;
136 smgl::InputPort<ITKMesh::Pointer> mesh2D;
138 smgl::OutputPort<Metrics> error;
139
142
143private:
145 auto serialize_(bool /*useCache*/, const filesystem::path& /*cacheDir*/)
146 -> smgl::Metadata override;
147
150 const smgl::Metadata& meta,
151 const filesystem::path& /*cacheDir*/) override;
152};
153
160class PlotLStretchErrorNode : public smgl::Node
161{
162private:
168 cv::Mat cellMap_{};
172 bool drawLegend_{false};
174 cv::Mat l2Plot_{};
176 cv::Mat lInfPlot_{};
177
178public:
180 smgl::InputPort<Metrics> error;
182 smgl::InputPort<cv::Mat> cellMap;
184 smgl::InputPort<ColorMap> colorMap;
186 smgl::InputPort<bool> drawLegend;
188 smgl::OutputPort<cv::Mat> l2Plot;
190 smgl::OutputPort<cv::Mat> lInfPlot;
191
194
195private:
197 auto serialize_(bool useCache, const filesystem::path& cacheDir)
198 -> smgl::Metadata override;
199
202 const smgl::Metadata& meta, const filesystem::path& cacheDir) override;
203};
204
211class PPMGeneratorNode : public smgl::Node
212{
213private:
222
223public:
230 smgl::InputPort<ITKMesh::Pointer> mesh;
232 smgl::InputPort<UVMap::Pointer> uvMap;
234 smgl::InputPort<Shading> shading;
236 smgl::OutputPort<PerPixelMap::Pointer> ppm;
237
240
241private:
243 auto serialize_(bool useCache, const filesystem::path& cacheDir)
244 -> smgl::Metadata override;
245
248 const smgl::Metadata& meta, const filesystem::path& cacheDir) override;
249};
250
257class CalculateNeighborhoodRadiusNode : public smgl::Node
258{
259private:
261 double thickness_{300};
263 double voxelSize_{100};
265 cv::Vec3d radius_;
266
267public:
272 smgl::InputPort<double> thickness;
274 smgl::InputPort<double> voxelSize;
276 smgl::OutputPort<cv::Vec3d> radius;
277
280
281private:
283 auto serialize_(bool /*useCache*/, const filesystem::path& /*cacheDir*/)
284 -> smgl::Metadata override;
285
288 const smgl::Metadata& meta,
289 const filesystem::path& /*cacheDir*/) override;
290};
291
297class NeighborhoodGeneratorNode : public smgl::Node
298{
299public:
301 enum class Shape {
303 Line = 0,
305 Cuboid
306 };
307
308private:
314 cv::Vec3d radius_{1, 1, 1};
316 double interval_{1};
321
322public:
324 smgl::InputPort<Shape> shape;
326 smgl::InputPort<cv::Vec3d> radius;
328 smgl::InputPort<double> interval;
333 smgl::InputPort<Direction> direction;
335 smgl::OutputPort<Generator::Pointer> generator;
336
339
340private:
342 auto serialize_(bool /*useCache*/, const filesystem::path& /*cacheDir*/)
343 -> smgl::Metadata override;
344
347 const smgl::Metadata& meta,
348 const filesystem::path& /*cacheDir*/) override;
349};
350
356class CompositeTextureNode : public smgl::Node
357{
358private:
368 cv::Mat texture_;
369
370public:
373
375 smgl::InputPort<PerPixelMap::Pointer> ppm;
377 smgl::InputPort<Volume::Pointer> volume;
379 smgl::InputPort<Generator> generator;
381 smgl::InputPort<Filter> filter;
383 smgl::OutputPort<cv::Mat> texture;
384
387
388private:
390 auto serialize_(bool useCache, const filesystem::path& cacheDir)
391 -> smgl::Metadata override;
392
395 const smgl::Metadata& meta, const filesystem::path& cacheDir) override;
396};
397
403class IntersectionTextureNode : public smgl::Node
404{
405private:
411 cv::Mat texture_;
412
413public:
415 smgl::InputPort<PerPixelMap::Pointer> ppm;
417 smgl::InputPort<Volume::Pointer> volume;
419 smgl::OutputPort<cv::Mat> texture;
420
423
424private:
426 auto serialize_(bool useCache, const filesystem::path& cacheDir)
427 -> smgl::Metadata override;
428
431 const smgl::Metadata& meta, const filesystem::path& cacheDir) override;
432};
433
439class IntegralTextureNode : public smgl::Node
440{
441private:
449 cv::Mat texture_;
450
451public:
467
469 smgl::InputPort<PerPixelMap::Pointer> ppm;
471 smgl::InputPort<Volume::Pointer> volume;
473 smgl::InputPort<Generator> generator;
475 smgl::InputPort<bool> clampValuesToMax;
477 smgl::InputPort<std::uint16_t> clampMax;
479 smgl::InputPort<WeightMethod> weightMethod;
481 smgl::InputPort<WeightDirection> linearWeightDirection;
483 smgl::InputPort<int> exponentialDiffExponent;
485 smgl::InputPort<ExpoDiffBaseMethod> exponentialDiffBaseMethod;
487 smgl::InputPort<double> exponentialDiffBaseValue;
489 smgl::InputPort<bool> exponentialDiffSuppressBelowBase;
491 smgl::OutputPort<cv::Mat> texture;
492
495
496private:
498 auto serialize_(bool useCache, const filesystem::path& cacheDir)
499 -> smgl::Metadata override;
500
503 const smgl::Metadata& meta, const filesystem::path& cacheDir) override;
504};
505
511class ThicknessTextureNode : public smgl::Node
512{
513private:
519 cv::Mat texture_;
520
521public:
523 smgl::InputPort<PerPixelMap::Pointer> ppm;
525 smgl::InputPort<Volume::Pointer> volume;
527 smgl::InputPort<VolumetricMask::Pointer> volumetricMask;
529 smgl::InputPort<double> samplingInterval;
531 smgl::InputPort<bool> normalizeOutput;
533 smgl::OutputPort<cv::Mat> texture;
534
537
538private:
540 auto serialize_(bool useCache, const filesystem::path& cacheDir)
541 -> smgl::Metadata override;
542
545 const smgl::Metadata& meta, const filesystem::path& cacheDir) override;
546};
547
553class LayerTextureNode : public smgl::Node
554{
555private:
557 using ImageList = std::vector<cv::Mat>;
566
567public:
569 smgl::InputPort<PerPixelMap::Pointer> ppm;
571 smgl::InputPort<Volume::Pointer> volume;
578 smgl::InputPort<Generator> generator;
580 smgl::OutputPort<ImageList> texture;
581
584
585private:
587 auto serialize_(bool useCache, const filesystem::path& cacheDir)
588 -> smgl::Metadata override;
589
592 const smgl::Metadata& meta, const filesystem::path& cacheDir) override;
593};
594} // namespace volcart
Parameterize a mesh using ABF++.
Definition: texturing.hpp:38
ITKMesh::Pointer mesh_
Definition: texturing.hpp:46
smgl::InputPort< bool > useHLSCM
Whether to use HierarchicalLSCM for parameterization.
Definition: texturing.hpp:54
smgl::InputPort< bool > useABF
Whether to perform Angle-based flattening computation.
Definition: texturing.hpp:52
smgl::OutputPort< ITKMesh::Pointer > output
Flattened mesh.
Definition: texturing.hpp:58
void deserialize_(const smgl::Metadata &meta, const filesystem::path &cacheDir) override
smgl::InputPort< ABF::Solver > solver
The numerical solver method.
Definition: texturing.hpp:56
smgl::InputPort< ITKMesh::Pointer > input
Input mesh.
Definition: texturing.hpp:50
UVMap::Pointer uvMap_
Definition: texturing.hpp:44
auto serialize_(bool useCache, const filesystem::path &cacheDir) -> smgl::Metadata override
smgl::OutputPort< UVMap::Pointer > uvMap
UVMap generated from flattened mesh.
Definition: texturing.hpp:60
Auto-calculate a texturing neighborhood's 3D radius in voxels given the expected layer thickness and ...
Definition: texturing.hpp:258
smgl::OutputPort< cv::Vec3d > radius
3D neighborhood radius
Definition: texturing.hpp:276
smgl::InputPort< double > voxelSize
Texturing Volume voxel size (um)
Definition: texturing.hpp:274
auto serialize_(bool, const filesystem::path &) -> smgl::Metadata override
smgl::InputPort< double > thickness
Estimated layer thickness (um)
Definition: texturing.hpp:272
void deserialize_(const smgl::Metadata &meta, const filesystem::path &) override
Generate a texture image using a variety of composite volume filters.
Definition: texturing.hpp:357
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:383
smgl::InputPort< Generator > generator
Neighborhood generator.
Definition: texturing.hpp:379
smgl::InputPort< Volume::Pointer > volume
Input Volume.
Definition: texturing.hpp:377
NeighborhoodGenerator::Pointer Generator
Definition: texturing.hpp:362
smgl::InputPort< PerPixelMap::Pointer > ppm
Input PerPixelMap.
Definition: texturing.hpp:375
smgl::InputPort< Filter > filter
Composite filter type.
Definition: texturing.hpp:381
Calculate the L2 and LInf stretch between a 2D and 3D mesh.
Definition: texturing.hpp:121
void deserialize_(const smgl::Metadata &meta, const filesystem::path &) override
smgl::InputPort< ITKMesh::Pointer > mesh3D
Input mesh (3D)
Definition: texturing.hpp:134
auto serialize_(bool, const filesystem::path &) -> smgl::Metadata override
smgl::InputPort< ITKMesh::Pointer > mesh2D
Input mesh (2D)
Definition: texturing.hpp:136
smgl::OutputPort< Metrics > error
Calculated error metrics.
Definition: texturing.hpp:138
ITKMesh::Pointer mesh2D_
Definition: texturing.hpp:128
ITKMesh::Pointer mesh3D_
Definition: texturing.hpp:126
Generate a Texture by taking the discrete integral (summation) of the neighborhood adjacent to a poin...
Definition: texturing.hpp:440
smgl::OutputPort< cv::Mat > texture
Generated texture image.
Definition: texturing.hpp:491
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:477
smgl::InputPort< bool > clampValuesToMax
When enabled, clamp neighborhood intensities to the value specified by setClampMax()
Definition: texturing.hpp:475
smgl::InputPort< int > exponentialDiffExponent
Set the weighting exponent used by Exponential Difference weighting.
Definition: texturing.hpp:483
smgl::InputPort< double > exponentialDiffBaseValue
Set the base value for Exponential Difference weighting.
Definition: texturing.hpp:487
smgl::InputPort< Generator > generator
Neighborhood generator.
Definition: texturing.hpp:473
smgl::InputPort< bool > exponentialDiffSuppressBelowBase
When enabled, do not integrate intensity values below the base value.
Definition: texturing.hpp:489
smgl::InputPort< PerPixelMap::Pointer > ppm
Input PerPixelMap.
Definition: texturing.hpp:469
auto serialize_(bool useCache, const filesystem::path &cacheDir) -> smgl::Metadata override
smgl::InputPort< Volume::Pointer > volume
Input Volume.
Definition: texturing.hpp:471
smgl::InputPort< ExpoDiffBaseMethod > exponentialDiffBaseMethod
Set the method used to calculate the Exponential Difference base value.
Definition: texturing.hpp:485
smgl::InputPort< WeightMethod > weightMethod
Set the weighting method.
Definition: texturing.hpp:479
smgl::InputPort< WeightDirection > linearWeightDirection
Set the linear weight direction.
Definition: texturing.hpp:481
NeighborhoodGenerator::Pointer Generator
Definition: texturing.hpp:445
Generate a Texture by intersection with a Volume.
Definition: texturing.hpp:404
smgl::InputPort< Volume::Pointer > volume
Input Volume.
Definition: texturing.hpp:417
smgl::InputPort< PerPixelMap::Pointer > ppm
Input PerPixelMap.
Definition: texturing.hpp:415
void deserialize_(const smgl::Metadata &meta, const filesystem::path &cacheDir) override
smgl::OutputPort< cv::Mat > texture
Generated texture image.
Definition: texturing.hpp:419
auto serialize_(bool useCache, const filesystem::path &cacheDir) -> smgl::Metadata override
Generate a Texture of layered images.
Definition: texturing.hpp:554
NeighborhoodGenerator::Pointer Generator
Definition: texturing.hpp:561
smgl::InputPort< PerPixelMap::Pointer > ppm
Input PerPixelMap.
Definition: texturing.hpp:569
smgl::InputPort< Volume::Pointer > volume
Input Volume.
Definition: texturing.hpp:571
smgl::InputPort< Generator > generator
Neighborhood generator.
Definition: texturing.hpp:578
std::vector< cv::Mat > ImageList
Definition: texturing.hpp:557
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:580
Configure a NeighborhoodGenerator for use by a texturing algorithm.
Definition: texturing.hpp:298
smgl::OutputPort< Generator::Pointer > generator
Configured neighborhood generator.
Definition: texturing.hpp:335
smgl::InputPort< Shape > shape
Neighborhood shape.
Definition: texturing.hpp:324
void deserialize_(const smgl::Metadata &meta, const filesystem::path &) override
smgl::InputPort< Direction > direction
Sampling direction.
Definition: texturing.hpp:333
auto serialize_(bool, const filesystem::path &) -> smgl::Metadata override
smgl::InputPort< double > interval
Sampling rate along the radius.
Definition: texturing.hpp:328
smgl::InputPort< cv::Vec3d > radius
3D neighborhood radius
Definition: texturing.hpp:326
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:82
void deserialize_(const smgl::Metadata &meta, const filesystem::path &cacheDir) override
smgl::InputPort< ITKMesh::Pointer > input
Input mesh.
Definition: texturing.hpp:95
smgl::OutputPort< ITKMesh::Pointer > output
Flattened mesh.
Definition: texturing.hpp:97
smgl::OutputPort< UVMap::Pointer > uvMap
UVMap generated from flattened mesh.
Definition: texturing.hpp:99
auto serialize_(bool useCache, const filesystem::path &cacheDir) -> smgl::Metadata override
Generates a PerPixelMap from an ITKMesh and a UVMap.
Definition: texturing.hpp:212
smgl::OutputPort< PerPixelMap::Pointer > ppm
Output PerPixelMap.
Definition: texturing.hpp:236
smgl::InputPort< ITKMesh::Pointer > mesh
Input mesh.
Definition: texturing.hpp:230
auto serialize_(bool useCache, const filesystem::path &cacheDir) -> smgl::Metadata override
PerPixelMap::Pointer ppm_
Definition: texturing.hpp:221
PPMGen::Shading shading_
Definition: texturing.hpp:219
smgl::InputPort< UVMap::Pointer > uvMap
Input UVMap.
Definition: texturing.hpp:232
smgl::InputPort< Shading > shading
Pixel normal shading method.
Definition: texturing.hpp:234
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:161
auto serialize_(bool useCache, const filesystem::path &cacheDir) -> smgl::Metadata override
smgl::InputPort< Metrics > error
Input error metrics.
Definition: texturing.hpp:180
smgl::InputPort< ColorMap > colorMap
Color map/LUT for visualization.
Definition: texturing.hpp:184
smgl::OutputPort< cv::Mat > lInfPlot
LInf error image.
Definition: texturing.hpp:190
smgl::InputPort< bool > drawLegend
Whether to add a legend to the image.
Definition: texturing.hpp:186
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:182
smgl::OutputPort< cv::Mat > l2Plot
L2 error image.
Definition: texturing.hpp:188
Generate a Texture using the thickness of the segmented layer.
Definition: texturing.hpp:512
smgl::InputPort< double > samplingInterval
Set the sampling interval.
Definition: texturing.hpp:529
smgl::InputPort< VolumetricMask::Pointer > volumetricMask
VolumetricMask for a single layer.
Definition: texturing.hpp:527
void deserialize_(const smgl::Metadata &meta, const filesystem::path &cacheDir) override
smgl::InputPort< bool > normalizeOutput
Normalize the output image.
Definition: texturing.hpp:531
auto serialize_(bool useCache, const filesystem::path &cacheDir) -> smgl::Metadata override
smgl::InputPort< Volume::Pointer > volume
Input Volume.
Definition: texturing.hpp:525
smgl::InputPort< PerPixelMap::Pointer > ppm
Input PerPixelMap.
Definition: texturing.hpp:523
smgl::OutputPort< cv::Mat > texture
Generated texture image.
Definition: texturing.hpp:533
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.