45 template<
typename dtype>
57 double rowCenter = 0.;
58 double colCenter = 0.;
64 const auto pixelValue =
static_cast<double>(inArray(row, col));
67 rowCenter += pixelValue *
static_cast<double>(row);
68 colCenter += pixelValue *
static_cast<double>(col);
75 return { rowCenter, colCenter };
84 for (
uint32 colIdx = 0; colIdx <
shape.cols; ++colIdx)
86 for (
uint32 rowIdx = 0; rowIdx <
shape.rows; ++rowIdx)
88 returnArray(0, colIdx) +=
89 static_cast<double>(inArray(rowIdx, colIdx)) *
static_cast<double>(rowIdx);
92 returnArray(0, colIdx) /= inten[colIdx];
104 for (
uint32 rowIdx = 0; rowIdx <
shape.rows; ++rowIdx)
106 for (
uint32 colIdx = 0; colIdx <
shape.cols; ++colIdx)
108 returnArray(0, rowIdx) +=
109 static_cast<double>(inArray(rowIdx, colIdx)) *
static_cast<double>(colIdx);
112 returnArray(0, rowIdx) /= inten[rowIdx];
#define THROW_INVALID_ARGUMENT_ERROR(msg)
Definition Error.hpp:37
#define STATIC_ASSERT_ARITHMETIC(dtype)
Definition StaticAsserts.hpp:39
Holds 1D and 2D arrays, the main work horse of the NumCpp library.
Definition NdArrayCore.hpp:135
self_type & zeros() noexcept
Definition NdArrayCore.hpp:4977
const Shape & shape() const noexcept
Definition NdArrayCore.hpp:4587
self_type sum(Axis inAxis=Axis::NONE) const
Definition NdArrayCore.hpp:4694
A Shape Class for NdArrays.
Definition Core/shape.hpp:41
Definition Cartesian.hpp:39
Axis
Enum To describe an axis.
Definition Enums.hpp:36
@ ROW
Definition Enums.hpp:38
@ COL
Definition Enums.hpp:39
@ NONE
Definition Enums.hpp:37
NdArray< double > centerOfMass(const NdArray< dtype > &inArray, Axis inAxis=Axis::NONE)
Definition centerOfMass.hpp:46
Shape shape(const NdArray< dtype > &inArray) noexcept
Definition Functions/shape.hpp:42
NdArray< dtypeOut > astype(const NdArray< dtype > inArray)
Definition astype.hpp:43
std::uint32_t uint32
Definition Types.hpp:40