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<ABF::Solver> solver;
56 smgl::OutputPort<ITKMesh::Pointer> output;
58 smgl::OutputPort<UVMap::Pointer> uvMap;
59
62
63private:
65 auto serialize_(bool useCache, const filesystem::path& cacheDir)
66 -> smgl::Metadata override;
67
70 const smgl::Metadata& meta, const filesystem::path& cacheDir) override;
71};
72
79class OrthographicFlatteningNode : public smgl::Node
80{
81private:
89 ITKMesh::Pointer mesh_{nullptr};
90
91public:
93 smgl::InputPort<ITKMesh::Pointer> input;
95 smgl::OutputPort<ITKMesh::Pointer> output;
97 smgl::OutputPort<UVMap::Pointer> uvMap;
98
101
102private:
104 auto serialize_(bool useCache, const filesystem::path& cacheDir)
105 -> smgl::Metadata override;
106
109 const smgl::Metadata& meta, const filesystem::path& cacheDir) override;
110};
111
118class FlatteningErrorNode : public smgl::Node
119{
120private:
124 ITKMesh::Pointer mesh3D_{nullptr};
126 ITKMesh::Pointer mesh2D_{nullptr};
129
130public:
132 smgl::InputPort<ITKMesh::Pointer> mesh3D;
134 smgl::InputPort<ITKMesh::Pointer> mesh2D;
136 smgl::OutputPort<Metrics> error;
137
140
141private:
143 auto serialize_(bool /*useCache*/, const filesystem::path& /*cacheDir*/)
144 -> smgl::Metadata override;
145
148 const smgl::Metadata& meta,
149 const filesystem::path& /*cacheDir*/) override;
150};
151
158class PlotLStretchErrorNode : public smgl::Node
159{
160private:
166 cv::Mat cellMap_{};
170 bool drawLegend_{false};
172 cv::Mat l2Plot_{};
174 cv::Mat lInfPlot_{};
175
176public:
178 smgl::InputPort<Metrics> error;
180 smgl::InputPort<cv::Mat> cellMap;
182 smgl::InputPort<ColorMap> colorMap;
184 smgl::InputPort<bool> drawLegend;
186 smgl::OutputPort<cv::Mat> l2Plot;
188 smgl::OutputPort<cv::Mat> lInfPlot;
189
192
193private:
195 auto serialize_(bool useCache, const filesystem::path& cacheDir)
196 -> smgl::Metadata override;
197
200 const smgl::Metadata& meta, const filesystem::path& cacheDir) override;
201};
202
209class PPMGeneratorNode : public smgl::Node
210{
211private:
220
221public:
228 smgl::InputPort<ITKMesh::Pointer> mesh;
230 smgl::InputPort<UVMap::Pointer> uvMap;
232 smgl::InputPort<Shading> shading;
234 smgl::OutputPort<PerPixelMap::Pointer> ppm;
235
238
239private:
241 auto serialize_(bool useCache, const filesystem::path& cacheDir)
242 -> smgl::Metadata override;
243
246 const smgl::Metadata& meta, const filesystem::path& cacheDir) override;
247};
248
255class CalculateNeighborhoodRadiusNode : public smgl::Node
256{
257private:
259 double thickness_{300};
261 double voxelSize_{100};
263 cv::Vec3d radius_;
264
265public:
270 smgl::InputPort<double> thickness;
272 smgl::InputPort<double> voxelSize;
274 smgl::OutputPort<cv::Vec3d> radius;
275
278
279private:
281 auto serialize_(bool /*useCache*/, const filesystem::path& /*cacheDir*/)
282 -> smgl::Metadata override;
283
286 const smgl::Metadata& meta,
287 const filesystem::path& /*cacheDir*/) override;
288};
289
295class NeighborhoodGeneratorNode : public smgl::Node
296{
297public:
299 enum class Shape {
301 Line = 0,
303 Cuboid
304 };
305
306private:
312 cv::Vec3d radius_{1, 1, 1};
314 double interval_{1};
319
320public:
322 smgl::InputPort<Shape> shape;
324 smgl::InputPort<cv::Vec3d> radius;
326 smgl::InputPort<double> interval;
331 smgl::InputPort<Direction> direction;
333 smgl::OutputPort<Generator::Pointer> generator;
334
337
338private:
340 auto serialize_(bool /*useCache*/, const filesystem::path& /*cacheDir*/)
341 -> smgl::Metadata override;
342
345 const smgl::Metadata& meta,
346 const filesystem::path& /*cacheDir*/) override;
347};
348
354class CompositeTextureNode : public smgl::Node
355{
356private:
366 cv::Mat texture_;
367
368public:
371
373 smgl::InputPort<PerPixelMap::Pointer> ppm;
375 smgl::InputPort<Volume::Pointer> volume;
377 smgl::InputPort<Generator> generator;
379 smgl::InputPort<Filter> filter;
381 smgl::OutputPort<cv::Mat> texture;
382
385
386private:
388 auto serialize_(bool useCache, const filesystem::path& cacheDir)
389 -> smgl::Metadata override;
390
393 const smgl::Metadata& meta, const filesystem::path& cacheDir) override;
394};
395
401class IntersectionTextureNode : public smgl::Node
402{
403private:
409 cv::Mat texture_;
410
411public:
413 smgl::InputPort<PerPixelMap::Pointer> ppm;
415 smgl::InputPort<Volume::Pointer> volume;
417 smgl::OutputPort<cv::Mat> texture;
418
421
422private:
424 auto serialize_(bool useCache, const filesystem::path& cacheDir)
425 -> smgl::Metadata override;
426
429 const smgl::Metadata& meta, const filesystem::path& cacheDir) override;
430};
431
437class IntegralTextureNode : public smgl::Node
438{
439private:
447 cv::Mat texture_;
448
449public:
465
467 smgl::InputPort<PerPixelMap::Pointer> ppm;
469 smgl::InputPort<Volume::Pointer> volume;
471 smgl::InputPort<Generator> generator;
473 smgl::InputPort<bool> clampValuesToMax;
475 smgl::InputPort<std::uint16_t> clampMax;
477 smgl::InputPort<WeightMethod> weightMethod;
479 smgl::InputPort<WeightDirection> linearWeightDirection;
481 smgl::InputPort<int> exponentialDiffExponent;
483 smgl::InputPort<ExpoDiffBaseMethod> exponentialDiffBaseMethod;
485 smgl::InputPort<double> exponentialDiffBaseValue;
487 smgl::InputPort<bool> exponentialDiffSuppressBelowBase;
489 smgl::OutputPort<cv::Mat> texture;
490
493
494private:
496 auto serialize_(bool useCache, const filesystem::path& cacheDir)
497 -> smgl::Metadata override;
498
501 const smgl::Metadata& meta, const filesystem::path& cacheDir) override;
502};
503
509class ThicknessTextureNode : public smgl::Node
510{
511private:
517 cv::Mat texture_;
518
519public:
521 smgl::InputPort<PerPixelMap::Pointer> ppm;
523 smgl::InputPort<Volume::Pointer> volume;
525 smgl::InputPort<VolumetricMask::Pointer> volumetricMask;
527 smgl::InputPort<double> samplingInterval;
529 smgl::InputPort<bool> normalizeOutput;
531 smgl::OutputPort<cv::Mat> texture;
532
535
536private:
538 auto serialize_(bool useCache, const filesystem::path& cacheDir)
539 -> smgl::Metadata override;
540
543 const smgl::Metadata& meta, const filesystem::path& cacheDir) override;
544};
545
551class LayerTextureNode : public smgl::Node
552{
553private:
555 using ImageList = std::vector<cv::Mat>;
564
565public:
567 smgl::InputPort<PerPixelMap::Pointer> ppm;
569 smgl::InputPort<Volume::Pointer> volume;
576 smgl::InputPort<Generator> generator;
578 smgl::OutputPort<ImageList> texture;
579
582
583private:
585 auto serialize_(bool useCache, const filesystem::path& cacheDir)
586 -> smgl::Metadata override;
587
590 const smgl::Metadata& meta, const filesystem::path& cacheDir) override;
591};
592} // namespace volcart
Parameterize a mesh using ABF++.
Definition: texturing.hpp:38
ITKMesh::Pointer mesh_
Definition: texturing.hpp:46
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:56
void deserialize_(const smgl::Metadata &meta, const filesystem::path &cacheDir) override
smgl::InputPort< ABF::Solver > solver
The numerical solver method.
Definition: texturing.hpp:54
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:58
Auto-calculate a texturing neighborhood's 3D radius in voxels given the expected layer thickness and ...
Definition: texturing.hpp:256
smgl::OutputPort< cv::Vec3d > radius
3D neighborhood radius
Definition: texturing.hpp:274
smgl::InputPort< double > voxelSize
Texturing Volume voxel size (um)
Definition: texturing.hpp:272
auto serialize_(bool, const filesystem::path &) -> smgl::Metadata override
smgl::InputPort< double > thickness
Estimated layer thickness (um)
Definition: texturing.hpp:270
void deserialize_(const smgl::Metadata &meta, const filesystem::path &) override
Generate a texture image using a variety of composite volume filters.
Definition: texturing.hpp:355
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:381
smgl::InputPort< Generator > generator
Neighborhood generator.
Definition: texturing.hpp:377
smgl::InputPort< Volume::Pointer > volume
Input Volume.
Definition: texturing.hpp:375
NeighborhoodGenerator::Pointer Generator
Definition: texturing.hpp:360
smgl::InputPort< PerPixelMap::Pointer > ppm
Input PerPixelMap.
Definition: texturing.hpp:373
smgl::InputPort< Filter > filter
Composite filter type.
Definition: texturing.hpp:379
Calculate the L2 and LInf stretch between a 2D and 3D mesh.
Definition: texturing.hpp:119
void deserialize_(const smgl::Metadata &meta, const filesystem::path &) override
smgl::InputPort< ITKMesh::Pointer > mesh3D
Input mesh (3D)
Definition: texturing.hpp:132
auto serialize_(bool, const filesystem::path &) -> smgl::Metadata override
smgl::InputPort< ITKMesh::Pointer > mesh2D
Input mesh (2D)
Definition: texturing.hpp:134
smgl::OutputPort< Metrics > error
Calculated error metrics.
Definition: texturing.hpp:136
ITKMesh::Pointer mesh2D_
Definition: texturing.hpp:126
ITKMesh::Pointer mesh3D_
Definition: texturing.hpp:124
Generate a Texture by taking the discrete integral (summation) of the neighborhood adjacent to a poin...
Definition: texturing.hpp:438
smgl::OutputPort< cv::Mat > texture
Generated texture image.
Definition: texturing.hpp:489
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:475
smgl::InputPort< bool > clampValuesToMax
When enabled, clamp neighborhood intensities to the value specified by setClampMax()
Definition: texturing.hpp:473
smgl::InputPort< int > exponentialDiffExponent
Set the weighting exponent used by Exponential Difference weighting.
Definition: texturing.hpp:481
smgl::InputPort< double > exponentialDiffBaseValue
Set the base value for Exponential Difference weighting.
Definition: texturing.hpp:485
smgl::InputPort< Generator > generator
Neighborhood generator.
Definition: texturing.hpp:471
smgl::InputPort< bool > exponentialDiffSuppressBelowBase
When enabled, do not integrate intensity values below the base value.
Definition: texturing.hpp:487
smgl::InputPort< PerPixelMap::Pointer > ppm
Input PerPixelMap.
Definition: texturing.hpp:467
auto serialize_(bool useCache, const filesystem::path &cacheDir) -> smgl::Metadata override
smgl::InputPort< Volume::Pointer > volume
Input Volume.
Definition: texturing.hpp:469
smgl::InputPort< ExpoDiffBaseMethod > exponentialDiffBaseMethod
Set the method used to calculate the Exponential Difference base value.
Definition: texturing.hpp:483
smgl::InputPort< WeightMethod > weightMethod
Set the weighting method.
Definition: texturing.hpp:477
smgl::InputPort< WeightDirection > linearWeightDirection
Set the linear weight direction.
Definition: texturing.hpp:479
NeighborhoodGenerator::Pointer Generator
Definition: texturing.hpp:443
Generate a Texture by intersection with a Volume.
Definition: texturing.hpp:402
smgl::InputPort< Volume::Pointer > volume
Input Volume.
Definition: texturing.hpp:415
smgl::InputPort< PerPixelMap::Pointer > ppm
Input PerPixelMap.
Definition: texturing.hpp:413
void deserialize_(const smgl::Metadata &meta, const filesystem::path &cacheDir) override
smgl::OutputPort< cv::Mat > texture
Generated texture image.
Definition: texturing.hpp:417
auto serialize_(bool useCache, const filesystem::path &cacheDir) -> smgl::Metadata override
Generate a Texture of layered images.
Definition: texturing.hpp:552
NeighborhoodGenerator::Pointer Generator
Definition: texturing.hpp:559
smgl::InputPort< PerPixelMap::Pointer > ppm
Input PerPixelMap.
Definition: texturing.hpp:567
smgl::InputPort< Volume::Pointer > volume
Input Volume.
Definition: texturing.hpp:569
smgl::InputPort< Generator > generator
Neighborhood generator.
Definition: texturing.hpp:576
std::vector< cv::Mat > ImageList
Definition: texturing.hpp:555
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:578
Configure a NeighborhoodGenerator for use by a texturing algorithm.
Definition: texturing.hpp:296
smgl::OutputPort< Generator::Pointer > generator
Configured neighborhood generator.
Definition: texturing.hpp:333
smgl::InputPort< Shape > shape
Neighborhood shape.
Definition: texturing.hpp:322
void deserialize_(const smgl::Metadata &meta, const filesystem::path &) override
smgl::InputPort< Direction > direction
Sampling direction.
Definition: texturing.hpp:331
auto serialize_(bool, const filesystem::path &) -> smgl::Metadata override
smgl::InputPort< double > interval
Sampling rate along the radius.
Definition: texturing.hpp:326
smgl::InputPort< cv::Vec3d > radius
3D neighborhood radius
Definition: texturing.hpp:324
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:80
void deserialize_(const smgl::Metadata &meta, const filesystem::path &cacheDir) override
smgl::InputPort< ITKMesh::Pointer > input
Input mesh.
Definition: texturing.hpp:93
smgl::OutputPort< ITKMesh::Pointer > output
Flattened mesh.
Definition: texturing.hpp:95
smgl::OutputPort< UVMap::Pointer > uvMap
UVMap generated from flattened mesh.
Definition: texturing.hpp:97
auto serialize_(bool useCache, const filesystem::path &cacheDir) -> smgl::Metadata override
Generates a PerPixelMap from an ITKMesh and a UVMap.
Definition: texturing.hpp:210
smgl::OutputPort< PerPixelMap::Pointer > ppm
Output PerPixelMap.
Definition: texturing.hpp:234
smgl::InputPort< ITKMesh::Pointer > mesh
Input mesh.
Definition: texturing.hpp:228
auto serialize_(bool useCache, const filesystem::path &cacheDir) -> smgl::Metadata override
PerPixelMap::Pointer ppm_
Definition: texturing.hpp:219
PPMGen::Shading shading_
Definition: texturing.hpp:217
smgl::InputPort< UVMap::Pointer > uvMap
Input UVMap.
Definition: texturing.hpp:230
smgl::InputPort< Shading > shading
Pixel normal shading method.
Definition: texturing.hpp:232
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:159
auto serialize_(bool useCache, const filesystem::path &cacheDir) -> smgl::Metadata override
smgl::InputPort< Metrics > error
Input error metrics.
Definition: texturing.hpp:178
smgl::InputPort< ColorMap > colorMap
Color map/LUT for visualization.
Definition: texturing.hpp:182
smgl::OutputPort< cv::Mat > lInfPlot
LInf error image.
Definition: texturing.hpp:188
smgl::InputPort< bool > drawLegend
Whether to add a legend to the image.
Definition: texturing.hpp:184
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:180
smgl::OutputPort< cv::Mat > l2Plot
L2 error image.
Definition: texturing.hpp:186
Generate a Texture using the thickness of the segmented layer.
Definition: texturing.hpp:510
smgl::InputPort< double > samplingInterval
Set the sampling interval.
Definition: texturing.hpp:527
smgl::InputPort< VolumetricMask::Pointer > volumetricMask
VolumetricMask for a single layer.
Definition: texturing.hpp:525
void deserialize_(const smgl::Metadata &meta, const filesystem::path &cacheDir) override
smgl::InputPort< bool > normalizeOutput
Normalize the output image.
Definition: texturing.hpp:529
auto serialize_(bool useCache, const filesystem::path &cacheDir) -> smgl::Metadata override
smgl::InputPort< Volume::Pointer > volume
Input Volume.
Definition: texturing.hpp:523
smgl::InputPort< PerPixelMap::Pointer > ppm
Input PerPixelMap.
Definition: texturing.hpp:521
smgl::OutputPort< cv::Mat > texture
Generated texture image.
Definition: texturing.hpp:531
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.