Volume Cartographer 2.27.0
NeighborhoodGenerator.hpp
Go to the documentation of this file.
1#pragma once
2
5#include <cstddef>
6#include <cstdint>
7#include <memory>
8
11
12namespace volcart
13{
14
21
25enum class Direction {
27 Negative = -1,
29 Bidirectional = 0,
31 Positive = 1
32};
33
40{
41public:
43 using Pointer = std::shared_ptr<NeighborhoodGenerator>;
44
47 std::size_t dim() { return dim_; }
48
54 virtual Neighborhood::Extent extents() const = 0;
59 void setSamplingRadius(double r, std::size_t axis = 0)
60 {
61 radius_[axis] = r;
62 }
63
65 void setSamplingRadius(double r0, double r1, double r2)
66 {
67 radius_ = {r0, r1, r2};
68 }
69
71 void setSamplingRadius(const cv::Vec3d& radii) { radius_ = radii; }
72
79 void setSamplingInterval(double i) { interval_ = i; }
80
87
93 void setAutoGenAxes(bool b) { autoGenAxes_ = b; }
99 const Volume::Pointer& v,
100 const cv::Vec3d& pt,
101 const std::vector<cv::Vec3d>& axes) = 0;
104protected:
106 explicit NeighborhoodGenerator(std::size_t dim) : dim_{dim} {}
107
108 virtual ~NeighborhoodGenerator() = default;
109
111 const std::size_t dim_{0};
112
114 cv::Vec3d radius_{1.0, 1.0, 1.0};
115
117 double interval_{1.0};
118
121
123 bool autoGenAxes_{true};
124};
125
126} // namespace volcart
Dynamically-allocated N-Dimensional Array.
Definition: NDArray.hpp:29
std::vector< IndexType > Extent
Definition: NDArray.hpp:36
Base class for neighborhood generating classes.
std::size_t dim()
Get the dimensionality of the neighborhood generator.
virtual Neighborhood::Extent extents() const =0
Get the size of the neighborhood returned by this class.
void setSamplingDirection(Direction d)
Set the filtering search direction.
void setSamplingRadius(double r, std::size_t axis=0)
Set the sampling search radius by axis.
std::shared_ptr< NeighborhoodGenerator > Pointer
void setSamplingInterval(double i)
Set the sampling interval: how frequently along the radius (in Volume units) the samples are taken.
virtual Neighborhood compute(const Volume::Pointer &v, const cv::Vec3d &pt, const std::vector< cv::Vec3d > &axes)=0
Compute a neighborhood centered on a point.
void setSamplingRadius(double r0, double r1, double r2)
Set the sampling search radius for all axes.
void setAutoGenAxes(bool b)
Enable/Disable auto-generation of missing axes.
std::shared_ptr< Volume > Pointer
Definition: Volume.hpp:42
Volume Cartographer library
Direction
Neighborhood directional filtering options.
@ Positive
Only consider data in the positive normal direction.
@ Bidirectional
Consider data in both the positive and negative normal.
@ Negative
Only consider data in the negative normal direction.