Volume Cartographer 2.28.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);
56
58 [[nodiscard]] auto getTargetZIndex() const -> int;
59
62
67 void setAlpha(double a);
68
73 void setK1(double k);
74
79 void setK2(double k);
80
85 void setBeta(double b);
86
91 void setDelta(double d);
92
98 void setMaterialThickness(double m);
99
101 void setResliceSize(int s);
102
105
110
112 auto compute() -> PointSet override;
113
115 void setVisualize(bool b);
116
118 void setDumpVis(bool b);
119
121 [[nodiscard]] auto progressIterations() const -> std::size_t override;
122
123private:
129 auto estimate_normal_at_index_(const FittedCurve& currentCurve, int index)
130 -> cv::Vec3d;
131
139 [[nodiscard]] auto draw_particle_on_slice_(
140 const FittedCurve& curve,
141 int sliceIndex,
142 int particleIndex = -1,
143 bool showSpline = false) const -> cv::Mat;
144
146 auto create_final_pointset_(const std::vector<std::vector<Voxel>>& points)
147 -> PointSet;
148
150 constexpr static double DEFAULT_MIN_ENERGY_GRADIENT = 1e-7;
151
153 int endIndex_{0};
155 double alpha_{1.0 / 3.0};
157 double k1_{0.5};
159 double k2_{0.5};
161 double beta_{1.0 / 3.0};
163 double delta_{1.0 / 3.0};
167 bool considerPrevious_{false};
169 bool dumpVis_{false};
171 bool visualize_{false};
173 int numIters_{15};
178};
179} // 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:19
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 setTargetZIndex(int z)
Set the target z-index.
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.
auto getTargetZIndex() const -> int
Get the target z-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