Volume Cartographer 2.27.0
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Modules Pages
OpticalFlowSegmentation.hpp
Go to the documentation of this file.
1#pragma once
2
5#include <cstddef>
6#include <cstdint>
7#include <optional>
8
13
15{
32{
33public:
35 using Pointer = std::shared_ptr<OpticalFlowSegmentation>;
36
39
41 ~OpticalFlowSegmentation() override = default;
42
44 template <typename... Args>
45 static auto New(Args... args) -> Pointer
46 {
47 return std::make_shared<OpticalFlowSegmentation>(
48 std::forward<Args>(args)...);
49 }
50
52 void setTargetZIndex(int z);
53
58 void setOutsideThreshold(std::uint8_t outside);
59
65 void setOFThreshold(std::uint8_t ofThr);
66
71 void setOFDispThreshold(std::uint32_t ofDispThrs);
72
79 void setSmoothBrightnessThreshold(std::uint8_t brightness);
80
86 void setMaterialThickness(double m);
87
89 void setMaxThreads(std::uint32_t t);
90
93
95 void setVisualize(bool b);
96
98 void setDumpVis(bool b);
99
101 auto compute() -> PointSet override;
102
104 [[nodiscard]] auto progressIterations() const -> std::size_t override;
105
106private:
111 auto compute_curve_(const FittedCurve& currentCurve, int zIndex)
112 -> std::vector<Voxel>;
113
121 [[nodiscard]] auto draw_particle_on_slice_(
122 const FittedCurve& curve,
123 int sliceIndex,
124 int particleIndex = -1,
125 bool showSpline = false) const -> cv::Mat;
126
128 auto create_final_pointset_(const std::vector<std::vector<Voxel>>& points)
129 -> PointSet;
130
132 int endIndex_{0};
139 std::uint8_t outsideThreshold_{80};
164 std::uint8_t smoothByBrightness_{180};
168 std::optional<std::uint32_t> maxThreads_;
170 bool dumpVis_{false};
172 bool visualize_{false};
173};
174} // 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
void setOFDispThreshold(std::uint32_t ofDispThrs)
Set the maximum single pixel optical flow displacement before interpolating a pixel region.
void setTargetZIndex(int z)
Set the target z-index.
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.
OpticalFlowSegmentation()=default
Default constructor.
auto compute() -> PointSet override
Compute the segmentation.
void resetMaxThreads()
Clear the maximum number of threads.
auto create_final_pointset_(const std::vector< std::vector< Voxel > > &points) -> PointSet
Convert the internal storage array into a final PointSet.
void setMaxThreads(std::uint32_t t)
Set the maximum number of threads.
auto compute_curve_(const FittedCurve &currentCurve, int zIndex) -> std::vector< Voxel >
Compute the curve for z + 1 given a curve on z using the optical flow between the two slices.
void setOutsideThreshold(std::uint8_t outside)
Set the threshold of what pixel brightness is considered inside a sheet (higher as threshold) and out...
void setSmoothBrightnessThreshold(std::uint8_t brightness)
Set the threshold for what pixel brightness is considered as being outside the sheet....
void setOFThreshold(std::uint8_t ofThr)
Set the threshold of what pixel brightness is considered while calculating optical flow,...
auto progressIterations() const -> std::size_t override
Returns the maximum progress value.
Segmentation algorithms and utilities library