8#ifndef META_OCEAN_CV_NON_MAXIMUM_SUPPRESSION_H
9#define META_OCEAN_CV_NON_MAXIMUM_SUPPRESSION_H
56 template <
typename TCoordinate,
typename TStrength>
78 inline const TStrength&
strength()
const;
87 template <
bool tLeftLargerThanRight = true>
99 template <
typename TCoordinate,
typename TStrength>
135 template <
typename TCoordinate,
typename TStrength>
163 inline unsigned int x()
const;
216 inline unsigned int width()
const;
222 inline unsigned int height()
const;
228 inline unsigned int yOffset()
const;
238 inline void addCandidate(
const unsigned int x,
const unsigned int y,
const T& strength);
253 void addCandidates(
const T* values,
const unsigned int valuesPaddingElements,
const unsigned int firstColumn,
const unsigned int numberColumns,
const unsigned int firstRow,
const unsigned int numberRows,
const T& minimalThreshold,
Worker* worker);
270 bool candidate(
const unsigned int x,
const unsigned int y, T& strength)
const;
299 template <
typename TCoordinate,
typename TStrength,
bool tStrictMaximum = true, NonMaximumSuppression::SuppressionMode tSuppressionMode = NonMaximumSuppression::SM_MAXIMUM>
334 template <
typename TCoordinate,
typename TStrength,
bool tStrictMaximum>
347 template <
typename TFloat>
360 template <
typename TFloat>
376 void addCandidatesSubset(
const T* values,
const unsigned int valuesStrideElements,
const unsigned int firstColumn,
const unsigned int numberColumns,
const T* minimalThreshold,
const unsigned int firstRow,
const unsigned int numberRows);
393 template <
typename TCoordinate,
typename TStrength,
bool tStrictMaximum,
bool tOnlyPositive = false>
411 template <
typename TCoordinate,
typename TStrength,
bool tStrictMaximum,
bool tOnlyNegative = false>
423template <
typename TCoordinate,
typename TStrength>
431template <
typename TCoordinate,
typename TStrength>
437template <
typename TCoordinate,
typename TStrength>
438template <
bool tLeftLargerThanRight>
441 if constexpr (tLeftLargerThanRight)
482 *
this = std::move(nonMaximumSuppression);
487 width_(nonMaximumSuppression.width_),
488 rows_(nonMaximumSuppression.rows_)
528 if (
rows_[y].empty())
530 rows_[y].reserve(128);
533 rows_[y].emplace_back(x, strength);
537void NonMaximumSuppressionT<T>::addCandidates(
const T* values,
const unsigned int valuesPaddingElements,
const unsigned int firstColumn,
const unsigned int numberColumns,
const unsigned int firstRow,
const unsigned int numberRows,
const T& minimalThreshold,
Worker* worker)
539 ocean_assert(values !=
nullptr);
541 ocean_assert(firstColumn + numberColumns <=
width_);
545 const unsigned int valuesStrideElements =
width_ + valuesPaddingElements;
547 if (worker !=
nullptr)
549 worker->
executeFunction(
Worker::Function::create(*
this, &
NonMaximumSuppressionT<T>::addCandidatesSubset, values, valuesStrideElements, firstColumn, numberColumns, &minimalThreshold, 0u, 0u), firstRow, numberRows, 5u, 6u, 20u);
553 addCandidatesSubset(values, valuesStrideElements, firstColumn, numberColumns, &minimalThreshold, firstRow, numberRows);
564 while (!suppressionRow.empty())
566 if (suppressionRow.back().x() >= x)
568 suppressionRow.pop_back();
585 if (suppressionRow.empty())
591 size_t right = suppressionRow.
size() - 1;
593 while (left <= right)
595 const size_t mid = left + (right - left) / 2;
597 const unsigned int midX = suppressionRow[mid].x();
601 strength = suppressionRow[mid].strength();
625 ocean_assert(firstColumn + numberColumns <=
width_);
626 ocean_assert(firstRow + numberRows <= (
unsigned int)(
rows_.
endIndex()));
628 const unsigned int endColumn = firstColumn + numberColumns;
630 for (
unsigned int y = firstRow; y < firstRow + numberRows; ++y)
652template <
typename TCoordinate,
typename TStrength,
bool tStrictMaximum, NonMaximumSuppression::SuppressionMode tSuppressionMode>
655 ocean_assert(firstColumn + numberColumns <=
width_);
658 if (firstColumn + numberColumns >
width_)
668 strengthPositions.reserve(strengthPositions.size() + 128);
674 if (worker !=
nullptr)
677 worker->
executeFunction(
Worker::Function::create(*
this, &
NonMaximumSuppressionT<T>::suppressNonMaximumSubset<TCoordinate, TStrength, tStrictMaximum, tOnlyPositive>, &strengthPositions, firstColumn, numberColumns, &lock, positionCallback, 0u, 0u), firstRow, numberRows, 5u, 6u, 3u);
681 suppressNonMaximumSubset<TCoordinate, TStrength, tStrictMaximum, tOnlyPositive>(&strengthPositions, firstColumn, numberColumns,
nullptr, positionCallback, firstRow, numberRows);
690 if (worker !=
nullptr)
693 worker->
executeFunction(
Worker::Function::create(*
this, &
NonMaximumSuppressionT<T>::suppressNonMinimumSubset<TCoordinate, TStrength, tStrictMaximum, tOnlyNegative>, &strengthPositions, firstColumn, numberColumns, &lock, positionCallback, 0u, 0u), firstRow, numberRows, 5u, 6u, 3u);
697 suppressNonMinimumSubset<TCoordinate, TStrength, tStrictMaximum, tOnlyNegative>(&strengthPositions, firstColumn, numberColumns,
nullptr, positionCallback, firstRow, numberRows);
716 if (
this != &nonMaximumSuppression)
719 nonMaximumSuppression.width_ = 0u;
721 rows_ = std::move(nonMaximumSuppression.rows_);
730 if (
this != &nonMaximumSuppression)
740template <
typename TCoordinate,
typename TStrength,
bool tStrictMaximum>
748 const unsigned int horizontalBins = std::max(1u, (
width + binSize - 1u) / binSize);
749 const unsigned int verticalBins = std::max(1u, (
height + binSize - 1u) / binSize);
751 ocean_assert(binSize * horizontalBins >=
width);
752 ocean_assert(binSize * verticalBins >=
height);
758 for (
size_t n = 0; n < strengthPositions.size(); ++n)
762 ocean_assert((
unsigned int)(position.
x()) <
width);
763 ocean_assert((
unsigned int)(position.
y()) <
height);
765 const unsigned int xBin = (
unsigned int)(position.
x()) / binSize;
766 const unsigned int yBin = (
unsigned int)(position.
y()) / binSize;
768 ocean_assert(xBin <= horizontalBins);
769 ocean_assert(yBin <= verticalBins);
771 indexGroups[yBin * horizontalBins + xBin].emplace_back(
Index32(n));
774 std::vector<uint8_t> validPositions(strengthPositions.size(), 1u);
778 for (
size_t nCandidate = 0; nCandidate < strengthPositions.size(); ++nCandidate)
780 if (validPositions[nCandidate] == 0u)
788 const unsigned int xCandidateBin = (
unsigned int)(candidatePosition.
x()) / binSize;
789 const unsigned int yCandidateBin = (
unsigned int)(candidatePosition.
y()) / binSize;
791 ocean_assert(xCandidateBin <= horizontalBins);
792 ocean_assert(yCandidateBin <= verticalBins);
794 bool checkNextCandidate =
false;
796 for (
unsigned int yBin = (
unsigned int)(max(0,
int(yCandidateBin) - 1)); !checkNextCandidate && yBin < min(yCandidateBin + 2u, verticalBins); ++yBin)
798 for (
unsigned int xBin = (
unsigned int)(max(0,
int(xCandidateBin) - 1)); !checkNextCandidate && xBin < min(xCandidateBin + 2u, horizontalBins); ++xBin)
800 const Indices32& indices = indexGroups[yBin * horizontalBins + xBin];
802 for (
const Index32& nTest : indices)
804 if (nTest ==
Index32(nCandidate))
813 if (candidatePosition.
sqrDistance(testPosition) <= sqrRadius)
817 validPositions[nTest] = 0u;
821 validPositions[nCandidate] = 0u;
823 checkNextCandidate =
true;
830 if constexpr (tStrictMaximum)
834 validPositions[nCandidate] = 0u;
835 validPositions[nTest] = 0u;
837 checkNextCandidate =
true;
844 if (candidatePosition.
y() < testPosition.
y() || (candidatePosition.
y() == testPosition.
y() && candidatePosition.
x() < testPosition.
x()))
848 validPositions[nCandidate] = 0u;
850 checkNextCandidate =
true;
855 ocean_assert(testPosition.
y() < candidatePosition.
y() || (testPosition.
y() == candidatePosition.
y() && testPosition.
x() < candidatePosition.
x()));
859 validPositions[nTest] = 0u;
870 remainingPositions.reserve(strengthPositions.size());
874 ocean_assert(validIndices->empty());
876 validIndices->clear();
877 validIndices->reserve(strengthPositions.size());
879 for (
size_t n = 0; n < validPositions.size(); ++n)
881 if (validPositions[n])
883 remainingPositions.emplace_back(strengthPositions[n]);
884 validIndices->emplace_back(
Index32(n));
890 for (
size_t n = 0; n < validPositions.size(); ++n)
892 if (validPositions[n])
894 remainingPositions.emplace_back(strengthPositions[n]);
899 return remainingPositions;
903template <
typename TFloat>
906 static_assert(std::is_floating_point<TFloat>::value,
"Invalid floating point data type!");
919 const TFloat df = (TFloat(rightValue) - TFloat(leftValue)) * TFloat(0.5);
922 const TFloat dff = TFloat(leftValue) + TFloat(rightValue) - TFloat(middleValue) * TFloat(2);
926 location = TFloat(0);
930 const TFloat x = -df / dff;
932 if (x < TFloat(-1) || x > TFloat(1))
942template <
typename TFloat>
945 static_assert(std::is_floating_point<TFloat>::value,
"Invalid floating point data type!");
947 const T& value00 = topValues[0];
948 const T& value01 = topValues[1];
949 const T& value02 = topValues[2];
951 const T& value10 = centerValues[0];
952 const T& value11 = centerValues[1];
953 const T& value12 = centerValues[2];
955 const T& value20 = bottomValues[0];
956 const T& value21 = bottomValues[1];
957 const T& value22 = bottomValues[2];
961 ocean_assert(value11 >= value00 && value11 >= value01 && value11 >= value02);
962 ocean_assert(value11 >= value10 && value11 >= value12);
963 ocean_assert(value11 >= value20 && value11 >= value21 && value11 >= value22);
967 const TFloat dx = TFloat(value12 - value10) * TFloat(0.5);
968 const TFloat dy = TFloat(value21 - value01) * TFloat(0.5);
971 const TFloat dxx = TFloat(value12 + value10) - TFloat(value11) * TFloat(2);
972 const TFloat dyy = TFloat(value21 + value01) - TFloat(value11) * TFloat(2);
978 const TFloat dxy = TFloat(value22 + value00 - value20 - value02) * TFloat(0.25);
980 const TFloat denominator = dxx * dyy - dxy * dxy;
988 const TFloat factor = TFloat(1) / denominator;
990 const TFloat offsetX = -(dyy * dx - dxy * dy) * factor;
991 const TFloat offsetY = -(dxx * dy - dxy * dx) * factor;
993 if (offsetX < TFloat(-1) || offsetX > TFloat(1) || offsetY < TFloat(-1) || offsetY > TFloat(1))
1002template <
typename T>
1003void NonMaximumSuppressionT<T>::addCandidatesSubset(
const T* values,
const unsigned int valuesStrideElements,
const unsigned int firstColumn,
const unsigned int numberColumns,
const T* minimalThreshold,
const unsigned int firstRow,
const unsigned int numberRows)
1005 ocean_assert(values !=
nullptr);
1006 ocean_assert(valuesStrideElements >=
width_);
1007 ocean_assert(firstColumn + numberColumns <=
width_);
1012 const T localThreshold = *minimalThreshold;
1014 values += firstRow * valuesStrideElements;
1016 for (
unsigned int y = firstRow; y < firstRow + numberRows; ++y)
1018 for (
unsigned int x = firstColumn; x < firstColumn + numberColumns; ++x)
1020 if (values[x] >= localThreshold)
1026 values += valuesStrideElements;
1030template <
typename T>
1031template <
typename TCoordinate,
typename TStrength,
bool tStrictMaximum,
bool tOnlyPositive>
1034 ocean_assert(strengthPositions);
1036 ocean_assert(firstColumn + numberColumns <=
width_);
1038 ocean_assert(firstRow + numberRows <= (
unsigned int)
rows_.
endIndex());
1040 if (numberColumns < 3u || numberRows < 3u)
1045 const unsigned int firstCenterColumn = max(1u, firstColumn);
1046 const unsigned int endCenterColumn = min(firstColumn + numberColumns,
width_ - 1u);
1048 const unsigned int firstCenterRow = max((
unsigned int)
rows_.
firstIndex() + 1u, firstRow);
1049 const unsigned int endCenterRow = min(firstRow + numberRows, (
unsigned int)
rows_.
lastIndex());
1051 ocean_assert(firstCenterRow >= 1u);
1054 localStrengthPositions.reserve(100);
1056 for (
unsigned int y = firstCenterRow; y < endCenterRow; ++y)
1062 typename StrengthCandidateRow::const_iterator iRow0 = row0.
begin();
1063 typename StrengthCandidateRow::const_iterator iRow2 = row2.begin();
1065 typename StrengthCandidateRow::const_iterator iRow1Minus = row1.end();
1066 typename StrengthCandidateRow::const_iterator iRow1Plus = row1.size() > 1 ? row1.begin() + 1 : row1.end();
1068 for (
typename StrengthCandidateRow::const_iterator iRow1 = row1.begin(); iRow1 != row1.end(); ++iRow1)
1070 ocean_assert(iRow1->x() >= 0u && iRow1->x() + 1u <=
width_);
1073 if constexpr (tOnlyPositive)
1075 if (iRow1->strength() <= T(0))
1082 if (iRow1->x() >= firstCenterColumn && iRow1->x() < endCenterColumn && (iRow1Minus == row1.end() || iRow1Minus->x() + 1u != iRow1->x() || (tStrictMaximum && iRow1Minus->strength() < iRow1->strength()) || (!tStrictMaximum && iRow1Minus->strength() <= iRow1->strength())))
1085 if (iRow1Plus == row1.end() || iRow1Plus->x() != iRow1->x() + 1u || iRow1Plus->strength() < iRow1->strength())
1088 while (iRow0 != row0.end())
1090 if (iRow0->x() + 1u < iRow1->x())
1101 ocean_assert(iRow0 == row0.end() || iRow0->x() + 1u >= iRow1->x());
1103 if (iRow0 != row0.end() && iRow0->x() <= iRow1->x() + 1u)
1105 ocean_assert(iRow0->x() + 1u == iRow1->x() || iRow0->x() == iRow1->x() || iRow0->x() - 1u == iRow1->x());
1107 if ((tStrictMaximum && iRow0->strength() >= iRow1->strength()) || (!tStrictMaximum && iRow0->strength() > iRow1->strength()))
1114 const typename StrengthCandidateRow::const_iterator iRow0Plus = iRow0 + 1;
1116 if (iRow0Plus != row0.end() && iRow0Plus->x() <= iRow1->x() + 1u)
1118 if ((tStrictMaximum && iRow0Plus->strength() >= iRow1->strength()) || (!tStrictMaximum && iRow0Plus->strength() > iRow1->strength()))
1125 const typename StrengthCandidateRow::const_iterator iRow0PlusPlus = iRow0Plus + 1;
1127 if (iRow0PlusPlus != row0.end() && iRow0PlusPlus->x() <= iRow1->x() + 1u)
1129 ocean_assert(iRow0PlusPlus->x() == iRow1->x() + 1u);
1131 if ((tStrictMaximum && iRow0PlusPlus->strength() >= iRow1->strength()) || (!tStrictMaximum && iRow0PlusPlus->strength() > iRow1->strength()))
1141 while (iRow2 != row2.end())
1143 if (iRow2->x() + 1u < iRow1->x())
1154 ocean_assert(iRow2 == row2.end() || iRow2->x() + 1u >= iRow1->x());
1156 if (iRow2 != row2.end() && iRow2->x() <= iRow1->x() + 1u)
1158 ocean_assert(iRow2->x() + 1u == iRow1->x() || iRow2->x() == iRow1->x() || iRow2->x() - 1u == iRow1->x());
1160 if (iRow2->x() + 1u == iRow1->x())
1164 if ((tStrictMaximum && iRow2->strength() >= iRow1->strength()) || (!tStrictMaximum && iRow2->strength() > iRow1->strength()))
1171 if (iRow2->strength() >= iRow1->strength())
1179 const typename StrengthCandidateRow::const_iterator iRow2Plus = iRow2 + 1;
1181 if (iRow2Plus != row2.end() && iRow2Plus->x() <= iRow1->x() + 1u)
1183 if (iRow2Plus->strength() >= iRow1->strength())
1190 const typename StrengthCandidateRow::const_iterator iRow2PlusPlus = iRow2Plus + 1;
1192 if (iRow2PlusPlus != row2.end() && iRow2PlusPlus->x() <= iRow1->x() + 1u)
1194 ocean_assert(iRow2PlusPlus->x() == iRow1->x() + 1u);
1196 if (iRow2PlusPlus->strength() >= iRow1->strength())
1204 if (positionCallback !=
nullptr)
1208 TStrength preciseStrength;
1210 if ((*positionCallback)(iRow1->x(), y, iRow1->strength(), preciseX, preciseY, preciseStrength))
1212 localStrengthPositions.emplace_back(preciseX, preciseY, preciseStrength);
1226 if (iRow1Plus != row1.end())
1235 strengthPositions->insert(strengthPositions->end(), localStrengthPositions.begin(), localStrengthPositions.end());
1238template <
typename T>
1239template <
typename TCoordinate,
typename TStrength,
bool tStrictMaximum,
bool tOnlyNegative>
1242 ocean_assert(strengthPositions);
1244 ocean_assert(firstColumn + numberColumns <=
width_);
1246 ocean_assert(firstRow + numberRows <= (
unsigned int)
rows_.
endIndex());
1248 if (numberColumns < 3u || numberRows < 3u)
1253 const unsigned int firstCenterColumn = max(1u, firstColumn);
1254 const unsigned int endCenterColumn = min(firstColumn + numberColumns,
width_ - 1u);
1256 const unsigned int firstCenterRow = max((
unsigned int)
rows_.
firstIndex() + 1u, firstRow);
1257 const unsigned int endCenterRow = min(firstRow + numberRows, (
unsigned int)
rows_.
lastIndex());
1259 ocean_assert(firstCenterRow >= 1u);
1262 localStrengthPositions.reserve(100);
1264 for (
unsigned int y = firstCenterRow; y < endCenterRow; ++y)
1270 typename StrengthCandidateRow::const_iterator iRow0 = row0.
begin();
1271 typename StrengthCandidateRow::const_iterator iRow2 = row2.begin();
1273 typename StrengthCandidateRow::const_iterator iRow1Minus = row1.end();
1274 typename StrengthCandidateRow::const_iterator iRow1Plus = row1.size() > 1 ? row1.begin() + 1 : row1.end();
1276 for (
typename StrengthCandidateRow::const_iterator iRow1 = row1.begin(); iRow1 != row1.end(); ++iRow1)
1278 ocean_assert(iRow1->x() >= 0u && iRow1->x() + 1u <=
width_);
1281 if constexpr (tOnlyNegative)
1283 if (iRow1->strength() >= T(0))
1290 if (iRow1->x() >= firstCenterColumn && iRow1->x() < endCenterColumn && (iRow1Minus == row1.end() || iRow1Minus->x() + 1u != iRow1->x() || (tStrictMaximum && iRow1Minus->strength() > iRow1->strength()) || (!tStrictMaximum && iRow1Minus->strength() >= iRow1->strength())))
1293 if (iRow1Plus == row1.end() || iRow1Plus->x() != iRow1->x() + 1u || iRow1Plus->strength() > iRow1->strength())
1296 while (iRow0 != row0.end())
1298 if (iRow0->x() + 1u < iRow1->x())
1309 ocean_assert(iRow0 == row0.end() || iRow0->x() + 1u >= iRow1->x());
1311 if (iRow0 != row0.end() && iRow0->x() <= iRow1->x() + 1u)
1313 ocean_assert(iRow0->x() + 1u == iRow1->x() || iRow0->x() == iRow1->x() || iRow0->x() - 1u == iRow1->x());
1315 if ((tStrictMaximum && iRow0->strength() <= iRow1->strength()) || (!tStrictMaximum && iRow0->strength() < iRow1->strength()))
1322 const typename StrengthCandidateRow::const_iterator iRow0Plus = iRow0 + 1;
1324 if (iRow0Plus != row0.end() && iRow0Plus->x() <= iRow1->x() + 1u)
1326 if ((tStrictMaximum && iRow0Plus->strength() <= iRow1->strength()) || (!tStrictMaximum && iRow0Plus->strength() < iRow1->strength()))
1333 const typename StrengthCandidateRow::const_iterator iRow0PlusPlus = iRow0Plus + 1;
1335 if (iRow0PlusPlus != row0.end() && iRow0PlusPlus->x() <= iRow1->x() + 1u)
1337 ocean_assert(iRow0PlusPlus->x() == iRow1->x() + 1u);
1339 if ((tStrictMaximum && iRow0PlusPlus->strength() <= iRow1->strength()) || (!tStrictMaximum && iRow0PlusPlus->strength() < iRow1->strength()))
1349 while (iRow2 != row2.end())
1351 if (iRow2->x() + 1u < iRow1->x())
1362 ocean_assert(iRow2 == row2.end() || iRow2->x() + 1u >= iRow1->x());
1364 if (iRow2 != row2.end() && iRow2->x() <= iRow1->x() + 1u)
1366 ocean_assert(iRow2->x() + 1u == iRow1->x() || iRow2->x() == iRow1->x() || iRow2->x() - 1u == iRow1->x());
1368 if (iRow2->x() + 1u == iRow1->x())
1372 if ((tStrictMaximum && iRow2->strength() <= iRow1->strength()) || (!tStrictMaximum && iRow2->strength() < iRow1->strength()))
1379 if (iRow2->strength() <= iRow1->strength())
1387 const typename StrengthCandidateRow::const_iterator iRow2Plus = iRow2 + 1;
1389 if (iRow2Plus != row2.end() && iRow2Plus->x() <= iRow1->x() + 1u)
1391 if (iRow2Plus->strength() <= iRow1->strength())
1398 const typename StrengthCandidateRow::const_iterator iRow2PlusPlus = iRow2Plus + 1;
1400 if (iRow2PlusPlus != row2.end() && iRow2PlusPlus->x() <= iRow1->x() + 1u)
1402 ocean_assert(iRow2PlusPlus->x() == iRow1->x() + 1u);
1404 if (iRow2PlusPlus->strength() <= iRow1->strength())
1412 if (positionCallback !=
nullptr)
1416 TStrength preciseStrength;
1418 if ((*positionCallback)(iRow1->x(), y, iRow1->strength(), preciseX, preciseY, preciseStrength))
1420 localStrengthPositions.emplace_back(preciseX, preciseY, preciseStrength);
1434 if (iRow1Plus != row1.end())
1443 strengthPositions->insert(strengthPositions->end(), localStrengthPositions.begin(), localStrengthPositions.end());
This class extends a 2D position by a third parameter storing a strength value.
Definition NonMaximumSuppression.h:58
const TStrength & strength() const
Returns the strength parameter of this object.
Definition NonMaximumSuppression.h:432
StrengthPosition()=default
Creates a new object with default strength parameter.
TStrength strength_
Strength parameter of this object.
Definition NonMaximumSuppression.h:93
static bool compareStrength(const StrengthPosition< TCoordinate, TStrength > &left, const StrengthPosition< TCoordinate, TStrength > &right)
Compares the strength value of two objects.
Definition NonMaximumSuppression.h:439
This class provides base functionality and type definitions for non-maximum-suppression operations.
Definition NonMaximumSuppression.h:33
SuppressionMode
Definition of individual suppression modes for extremum search.
Definition NonMaximumSuppression.h:40
@ SM_MAXIMUM
Finds the maximum values, any value is allowed.
Definition NonMaximumSuppression.h:42
@ SM_MINIMUM
Finds the minimum values, any value is allowed.
Definition NonMaximumSuppression.h:44
@ SM_MAXIMUM_POSITIVE_ONLY
Finds the maximum values, only positive values are allowed (> 0).
Definition NonMaximumSuppression.h:46
@ SM_MINIMUM_NEGATIVE_ONLY
Finds the minimum values, only negative values are allowed (< 0).
Definition NonMaximumSuppression.h:48
std::vector< StrengthPosition< TCoordinate, TStrength > > StrengthPositions
Definition of a vector holding strength pixel positions.
Definition NonMaximumSuppression.h:100
This class holds the horizontal position and strength parameter of an interest pixel.
Definition NonMaximumSuppression.h:144
StrengthCandidate()
Creates a new candidate object.
Definition NonMaximumSuppression.h:452
unsigned int positionX_
Horizontal position of this object.
Definition NonMaximumSuppression.h:174
const T & strength() const
Returns the strength parameter of this object.
Definition NonMaximumSuppression.h:474
unsigned int x() const
Returns the horizontal position of this candidate object.
Definition NonMaximumSuppression.h:468
T strength_
Strength parameter of this object.
Definition NonMaximumSuppression.h:177
This class implements the possibility to find local maximum in a 2D array by applying a non-maximum-s...
Definition NonMaximumSuppression.h:120
void suppressNonMaximumSubset(StrengthPositions< TCoordinate, TStrength > *strengthPositions, const unsigned int firstColumn, const unsigned int numberColumns, Lock *lock, const PositionCallback< TCoordinate, TStrength > *positionCallback, const unsigned int firstRow, const unsigned int numberRows) const
Applies a non-maximum-suppression search on a subset of a given 2D frame in a 3x3 neighborhood (eight...
Definition NonMaximumSuppression.h:1032
unsigned int yOffset() const
Returns the optional offset in the vertical direction.
Definition NonMaximumSuppression.h:514
void reset()
Removes the gathered non-maximum suppression information so that this object can be reused again (for...
Definition NonMaximumSuppression.h:705
static bool determinePrecisePeakLocation2(const T *const topValues, const T *const centerValues, const T *const bottomValues, VectorT2< TFloat > &location)
Determines the precise peak location in 2D space for nine discrete neighboring measurements at locati...
Definition NonMaximumSuppression.h:943
void addCandidate(const unsigned int x, const unsigned int y, const T &strength)
Adds a new candidate to this object.
Definition NonMaximumSuppression.h:522
static StrengthPositions< TCoordinate, TStrength > suppressNonMaximum(const unsigned int width, const unsigned int height, const StrengthPositions< TCoordinate, TStrength > &strengthPositions, const TCoordinate radius, Indices32 *validIndices=nullptr)
Applies a non-maximum-suppression based on already existing strength positions (just with a custom su...
void removeCandidatesRightFrom(const unsigned int x, const unsigned int y)
Removes all candidates from a specified row having a horizontal location equal or larger than a speci...
Definition NonMaximumSuppression.h:558
void candidates(const unsigned int firstColumn, const unsigned int numberColumns, const unsigned int firstRow, const unsigned int numberRows, StrengthPositions< unsigned int, T > &strengthPositions)
Returns all gathered candidates of this object.
Definition NonMaximumSuppression.h:623
unsigned int height() const
Returns the height of this object.
Definition NonMaximumSuppression.h:508
bool candidate(const unsigned int x, const unsigned int y, T &strength) const
Returns the strength value of a candidate at a specified position.
Definition NonMaximumSuppression.h:578
static bool determinePrecisePeakLocation1(const T &leftValue, const T &middleValue, const T &rightValue, TFloat &location)
Determines the precise peak location in 1D space for three discrete neighboring measurements at locat...
Definition NonMaximumSuppression.h:904
bool suppressNonMaximum(const unsigned int firstColumn, const unsigned int numberColumns, const unsigned int firstRow, const unsigned int numberRows, StrengthPositions< TCoordinate, TStrength > &strengthPositions, Worker *worker=nullptr, const PositionCallback< TCoordinate, TStrength > *positionCallback=nullptr) const
Applies a non-maximum-suppression search on a given 2D frame in a 3x3 neighborhood (eight neighbors).
Definition NonMaximumSuppression.h:653
NonMaximumSuppressionT< T > & operator=(NonMaximumSuppressionT< T > &&nonMaximumSuppression)
Move operator.
Definition NonMaximumSuppression.h:714
std::vector< StrengthCandidate > StrengthCandidateRow
Definition of a vector holding strength candidate objects.
Definition NonMaximumSuppression.h:183
std::function< bool(const unsigned int x, const unsigned int y, const TStrength strength, TCoordinate &preciseX, TCoordinate &preciseY, TStrength &preciseStrength)> PositionCallback
Definition of a callback function used to determine the precise sub-pixel position of a specific poin...
Definition NonMaximumSuppression.h:136
void suppressNonMinimumSubset(StrengthPositions< TCoordinate, TStrength > *strengthPositions, const unsigned int firstColumn, const unsigned int numberColumns, Lock *lock, const PositionCallback< TCoordinate, TStrength > *positionCallback, const unsigned int firstRow, const unsigned int numberRows) const
Applies a non-minimum-suppression search on a subset of a given 2D frame in a 3x3 neighborhood (eight...
Definition NonMaximumSuppression.h:1240
NonMaximumSuppressionT(NonMaximumSuppressionT< T > &&nonMaximumSuppression) noexcept
Move constructor.
Definition NonMaximumSuppression.h:480
void addCandidates(const T *values, const unsigned int valuesPaddingElements, const unsigned int firstColumn, const unsigned int numberColumns, const unsigned int firstRow, const unsigned int numberRows, const T &minimalThreshold, Worker *worker)
Adds new candidates to this object from a given buffer providing one value for each bin/pixel of this...
Definition NonMaximumSuppression.h:537
void addCandidatesSubset(const T *values, const unsigned int valuesStrideElements, const unsigned int firstColumn, const unsigned int numberColumns, const T *minimalThreshold, const unsigned int firstRow, const unsigned int numberRows)
Adds new candidates to this object from a subset of a given buffer providing one value for each bin/p...
Definition NonMaximumSuppression.h:1003
StrengthCandidateRows rows_
All candidate rows.
Definition NonMaximumSuppression.h:420
unsigned int width_
Width of this object.
Definition NonMaximumSuppression.h:417
unsigned int width() const
Returns the width of this object.
Definition NonMaximumSuppression.h:502
static Caller< void > create(CT &object, typename MemberFunctionPointerMaker< CT, void, NullClass, NullClass, NullClass, NullClass, NullClass, NullClass, NullClass, NullClass, NullClass, NullClass, NullClass, NullClass, NullClass, NullClass, NullClass, NullClass, NullClass, NullClass, NullClass, NullClass >::Type function)
Creates a new caller container for a member function with no function parameter.
Definition Caller.h:3024
This class implements a recursive lock object.
Definition Lock.h:31
This class provides basic numeric functionalities.
Definition Numeric.h:57
This class implements an optional recursive scoped lock object locking the lock object only if it's d...
Definition Lock.h:387
bool isValidIndex(const Index index) const
Returns whether a specific index is valid for this vector and matches to the current offset layout.
Definition ShiftVector.h:646
size_t size() const
Returns the number of elements that are stored by this object.
Definition ShiftVector.h:490
Index endIndex() const
Returns the index of the element behind the last (excluding) element of this object.
Definition ShiftVector.h:435
std::ptrdiff_t Index
Definition of an element index.
Definition ShiftVector.h:38
void clear()
Clears this object, the specified index shift will be untouched.
Definition ShiftVector.h:658
Iterator begin()
Returns the iterator for the first data element.
Definition ShiftVector.h:670
Index lastIndex() const
Returns the index of the last (including) element of this object.
Definition ShiftVector.h:422
Index firstIndex() const
Returns the index of the first element of this object.
Definition ShiftVector.h:416
This class implements a vector with two elements.
Definition Vector2.h:96
const TCoordinate & x() const noexcept
Returns the x value.
Definition Vector2.h:710
const TCoordinate & y() const noexcept
Returns the y value.
Definition Vector2.h:722
T sqrDistance(const VectorT2< T > &right) const
Returns the square distance between this 2D position and a second 2D position.
Definition Vector2.h:645
This class implements a worker able to distribute function calls over different threads.
Definition Worker.h:33
bool executeFunction(const Function &function, const unsigned int first, const unsigned int size, const unsigned int firstIndex=(unsigned int)(-1), const unsigned int sizeIndex=(unsigned int)(-1), const unsigned int minimalIterations=1u, const unsigned int threadIndex=(unsigned int)(-1))
Executes a callback function separable by two function parameters.
std::vector< Index32 > Indices32
Definition of a vector holding 32 bit index values.
Definition Base.h:96
std::vector< Indices32 > IndexGroups32
Definition of a vector holding 32 bit indices, so we have groups of indices.
Definition Base.h:102
uint32_t Index32
Definition of a 32 bit index value.
Definition Base.h:84
The namespace covering the entire Ocean framework.
Definition Accessor.h:15