Volume Cartographer 2.27.0
LocalResliceParticleSim.hpp
Go to the documentation of this file.
1#pragma once
2
5#include <cstddef>
6#include <iostream>
7
13
15{
35{
36public:
38 using Pointer = std::shared_ptr<LocalResliceSegmentation>;
39
42
44 ~LocalResliceSegmentation() override = default;
45
47 template <typename... Args>
48 static auto New(Args... args) -> Pointer
49 {
50 return std::make_shared<LocalResliceSegmentation>(
51 std::forward<Args>(args)...);
52 }
53
55 void setTargetZIndex(int z) { endIndex_ = z; }
56
59
64 void setAlpha(double a) { alpha_ = a; }
65
70 void setK1(double k) { k1_ = k; }
71
76 void setK2(double k) { k2_ = k; }
77
82 void setBeta(double b) { beta_ = b; }
83
88 void setDelta(double d) { delta_ = d; }
89
96
98 void setResliceSize(int s) { resliceSize_ = s; }
99
102
106
108 auto compute() -> PointSet override;
109
111 void setVisualize(bool b) { visualize_ = b; }
112
114 void setDumpVis(bool b) { dumpVis_ = b; }
115
117 [[nodiscard]] auto progressIterations() const -> std::size_t override;
118
119private:
125 auto estimate_normal_at_index_(const FittedCurve& currentCurve, int index)
126 -> cv::Vec3d;
127
135 [[nodiscard]] auto draw_particle_on_slice_(
136 const FittedCurve& curve,
137 int sliceIndex,
138 int particleIndex = -1,
139 bool showSpline = false) const -> cv::Mat;
140
142 auto create_final_pointset_(const std::vector<std::vector<Voxel>>& points)
143 -> PointSet;
144
146 constexpr static double DEFAULT_MIN_ENERGY_GRADIENT = 1e-7;
147
149 int endIndex_{0};
151 double alpha_{1.0 / 3.0};
153 double k1_{0.5};
155 double k2_{0.5};
157 double beta_{1.0 / 3.0};
159 double delta_{1.0 / 3.0};
163 bool considerPrevious_{false};
165 bool dumpVis_{false};
167 bool visualize_{false};
169 int numIters_{15};
174};
175} // namespace volcart::segmentation
Base class for segmentation algorithms that propagate a collected chain of points.
std::shared_ptr< ChainSegmentationAlgorithm > Pointer
Fits a curve to a set of points for resampling.
Definition: FittedCurve.hpp:20
Local Reslice Particle Simulation (LRPS) segmentation.
void setConsiderPrevious(bool b)
Set whether to consider previous position as candidate position.
void setMaterialThickness(double m)
Set the estimated thickness of the substrate (in um)
auto draw_particle_on_slice_(const FittedCurve &curve, int sliceIndex, int particleIndex=-1, bool showSpline=false) const -> cv::Mat
Debug: Draw curve on slice image.
void setOptimizationIterations(int n)
Set the number of curve optimization iterations per step.
void setDistanceWeightFactor(int f)
Set the distance weight factor for candidate positions.
void setDelta(double d)
Set the weight for the Arc Length metric.
void setBeta(double b)
Set the weight for the Absolute Curvature Sum metric.
void setResliceSize(int s)
Set the reslice window size.
auto estimate_normal_at_index_(const FittedCurve &currentCurve, int index) -> cv::Vec3d
Estimate the normal to the curve at point index.
LocalResliceSegmentation()=default
Default constructor.
auto create_final_pointset_(const std::vector< std::vector< Voxel > > &points) -> PointSet
Convert the internal storage array into a final PointSet.
void setK1(double k)
Set the stretch weight factor.
auto compute() -> PointSet override
Compute the segmentation.
void setAlpha(double a)
Set the weight for the Active Contour metric.
void setK2(double k)
Set the curvature weight factor.
auto progressIterations() const -> std::size_t override
Returns the maximum progress value.
Segmentation algorithms and utilities library