48 template<
typename dtype>
52 STATIC_ASSERT_ARITHMETIC(dtype);
55 using accumulator_t =
typename std::conditional<std::is_integral<dtype>::value,
int64,
double>::type;
73 centerOfMass(inCluster);
74 setEllipseProperties(inCluster);
83 [[nodiscard]]
double row() const noexcept
94 [[nodiscard]]
double col() const noexcept
116 [[nodiscard]]
double eod() const noexcept
127 [[nodiscard]]
double a() const noexcept
139 [[nodiscard]]
double b() const noexcept
152 return eccentricity_;
173 [[nodiscard]] std::string
str()
const
220 return !(*
this == rhs);
236 return intensity_ < rhs.intensity_ ? false :
true;
249 inStream << inCentriod.
str();
264 double eccentricity_{};
266 double orientation_{};
276 void centerOfMass(
const Cluster<dtype>& inCluster)
278 const Shape clusterShape(inCluster.height(), inCluster.width());
279 NdArray<dtype> clusterArray(clusterShape);
280 clusterArray.zeros();
282 const uint32 rowMin = inCluster.rowMin();
283 const uint32 colMin = inCluster.colMin();
285 for (
auto& pixel : inCluster)
287 clusterArray(pixel.row - rowMin, pixel.col - colMin) = pixel.intensity;
291 row_ = rowCol.front() + rowMin;
292 col_ = rowCol.back() + colMin;
301 void setEllipseProperties(
const Cluster<dtype>& inCluster)
noexcept
303 constexpr auto two =
static_cast<double>(2.);
305 auto m20 =
static_cast<double>(0.);
306 auto m02 =
static_cast<double>(0.);
307 auto m11 =
static_cast<double>(0.);
311 const auto& pixel = *iter;
312 const double deltaX = pixel.col - col_;
313 const double deltaY = pixel.row - row_;
315 m11 += deltaX * deltaY;
320 const auto numPixels =
static_cast<double>(inCluster.size());
325 double piece1 = m20 + m02;
331 const double lambda1 = piece1 - piece2;
332 const double lambda2 = piece1 + piece2;
334 eccentricity_ =
std::sqrt(
static_cast<double>(1.) - lambda1 / lambda2);
335 orientation_ =
static_cast<double>(-0.5) * std::atan2(two * m11, m20 - m02);
holds the information for a centroid
Definition: Centroid.hpp:50
bool operator<(const Centroid< dtype > &rhs) const noexcept
Definition: Centroid.hpp:234
double eod() const noexcept
Definition: Centroid.hpp:116
friend std::ostream & operator<<(std::ostream &inStream, const Centroid< dtype > &inCentriod)
Definition: Centroid.hpp:247
double b() const noexcept
Definition: Centroid.hpp:139
void print() const
Definition: Centroid.hpp:188
accumulator_t intensity() const noexcept
Definition: Centroid.hpp:105
double col() const noexcept
Definition: Centroid.hpp:94
bool operator==(const Centroid< dtype > &rhs) const noexcept
Definition: Centroid.hpp:201
Centroid(const Cluster< dtype > &inCluster)
Definition: Centroid.hpp:69
double eccentricity() const noexcept
Definition: Centroid.hpp:150
bool operator!=(const Centroid< dtype > &rhs) const noexcept
Definition: Centroid.hpp:218
double row() const noexcept
Definition: Centroid.hpp:83
std::string str() const
Definition: Centroid.hpp:173
typename std::conditional< std::is_integral< dtype >::value, int64, double >::type accumulator_t
Definition: Centroid.hpp:55
double a() const noexcept
Definition: Centroid.hpp:127
double orientation() const noexcept
Definition: Centroid.hpp:162
Holds the information for a cluster of pixels.
Definition: Cluster.hpp:53
typename std::vector< Pixel< dtype > >::const_iterator const_iterator
Definition: Cluster.hpp:59
Definition: applyThreshold.hpp:34
std::string num2str(dtype inNumber)
Definition: num2str.hpp:44
bool essentiallyEqual(dtype inValue1, dtype inValue2) noexcept
Definition: essentiallyEqual.hpp:49
constexpr dtype sqr(dtype inValue) noexcept
Definition: sqr.hpp:42
std::int64_t int64
Definition: Types.hpp:35
NdArray< double > centerOfMass(const NdArray< dtype > &inArray, Axis inAxis=Axis::NONE)
Definition: centerOfMass.hpp:47
auto sqrt(dtype inValue) noexcept
Definition: sqrt.hpp:48
std::uint32_t uint32
Definition: Types.hpp:40