This class implements the possibility to find local maximum in a 2D array by applying a non-maximum-suppression search.
More...
|
| template<typename TCoordinate , typename TStrength > |
| using | PositionCallback = std::function< bool(const unsigned int x, const unsigned int y, const TStrength strength, TCoordinate &preciseX, TCoordinate &preciseY, TStrength &preciseStrength)> |
| | Definition of a callback function used to determine the precise sub-pixel position of a specific point.
|
| |
| enum | SuppressionMode : uint32_t { SM_MAXIMUM
, SM_MINIMUM
, SM_MAXIMUM_POSITIVE_ONLY
, SM_MINIMUM_NEGATIVE_ONLY
} |
| | Definition of individual suppression modes for extremum search. More...
|
| |
| enum | RefinementStatus : uint32_t {
RS_INVALID = 0u
, RS_DIVERGED
, RS_BORDER
, RS_MAX_ITERATIONS
,
RS_CONVERGED
} |
| | Definition of individual refinement status values for iterative sub-pixel peak refinement. More...
|
| |
| template<typename TCoordinate , typename TStrength > |
| using | StrengthPositions = std::vector< StrengthPosition< TCoordinate, TStrength > > |
| | Definition of a vector holding strength pixel positions.
|
| |
|
| | NonMaximumSuppressionT (NonMaximumSuppressionT< T > &&nonMaximumSuppression) noexcept |
| | Move constructor.
|
| |
| | NonMaximumSuppressionT (const NonMaximumSuppressionT< T > &nonMaximumSuppression) noexcept |
| | Copy constructor.
|
| |
| | NonMaximumSuppressionT (const unsigned int width, const unsigned int height, const unsigned int yOffset=0u) noexcept |
| | Creates a new maximum suppression object with a predefined size.
|
| |
| unsigned int | width () const |
| | Returns the width of this object.
|
| |
| unsigned int | height () const |
| | Returns the height of this object.
|
| |
| unsigned int | yOffset () const |
| | Returns the optional offset in the vertical direction.
|
| |
| void | addCandidate (const unsigned int x, const unsigned int y, const T &strength) |
| | Adds a new candidate to this object.
|
| |
| 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 object.
|
| |
| 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 specified coordinate.
|
| |
| bool | candidate (const unsigned int x, const unsigned int y, T &strength) const |
| | Returns the strength value of a candidate at a specified position.
|
| |
| void | candidates (const unsigned int firstColumn, const unsigned int numberColumns, const unsigned int firstRow, const unsigned int numberRows, StrengthPositions< unsigned int, T > &strengthPositions) const |
| | Returns all gathered candidates of this object.
|
| |
| template<typename TCoordinate , typename TStrength , bool tStrictMaximum = true, NonMaximumSuppression::SuppressionMode tSuppressionMode = NonMaximumSuppression::SM_MAXIMUM> |
| 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).
|
| |
| void | reset () |
| | Removes the gathered non-maximum suppression information so that this object can be reused again (for the same task with same resolution etc.).
|
| |
| NonMaximumSuppressionT< T > & | operator= (NonMaximumSuppressionT< T > &&nonMaximumSuppression) |
| | Move operator.
|
| |
| NonMaximumSuppressionT< T > & | operator= (const NonMaximumSuppressionT< T > &nonMaximumSuppression) |
| | Copy operator.
|
| |
| template<typename TCoordinate , typename TStrength , bool tStrictMaximum> |
| NonMaximumSuppressionT< T >::template StrengthPositions< TCoordinate, TStrength > | suppressNonMaximum (const unsigned int width, const unsigned int height, const StrengthPositions< TCoordinate, TStrength > &strengthPositions, const TCoordinate radius, Indices32 *validIndices) |
| |
|
| template<typename TCoordinate , typename TStrength , bool tStrictMaximum> |
| 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 suppression radius) e.g., as a post-processing step.
|
| |
| template<typename TFloat > |
| 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 location x == 0.
|
| |
| template<typename TFloat > |
| 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 location x == 0, y == 0.
|
| |
| template<typename TFloat , unsigned int tSize, bool tFindMaximum = true> |
| static bool | determinePrecisePeakLocationNxN (const TFloat *values, const size_t valuesStrideElements, TFloat &offsetX, TFloat &offsetY) |
| | Determines the precise peak location in 2D space by fitting a quadratic surface via least-squares to a tSize x tSize grid of values.
|
| |
| template<typename TFloat , unsigned int tSize, bool tFindMaximum = true, PixelCenter tPixelCenter = PC_TOP_LEFT> |
| static NonMaximumSuppression::RefinementStatus | determinePrecisePeakLocationIterativeNxN (const uint8_t *frame, const unsigned int width, const unsigned int height, const unsigned int framePaddingElements, const TFloat x, const TFloat y, TFloat &preciseX, TFloat &preciseY, const unsigned int maxIterations=5u, const TFloat stepSize=TFloat(0.75), const TFloat convergenceThreshold=TFloat(0.01)) |
| | Determines the precise sub-pixel peak location by iteratively sampling image intensity values at sub-pixel positions.
|
| |
|
| 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/pixel of this object.
|
| |
| template<typename TCoordinate , typename TStrength , bool tStrictMaximum, bool tOnlyPositive = false> |
| 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 neighbors).
|
| |
| template<typename TCoordinate , typename TStrength , bool tStrictMaximum, bool tOnlyNegative = false> |
| 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 neighbors).
|
| |
template<typename T>
class Ocean::CV::NonMaximumSuppressionT< T >
This class implements the possibility to find local maximum in a 2D array by applying a non-maximum-suppression search.
The search is done within a 3x3 neighborhood (centered around the point of interest).
Use this class to determine e.g. reliable feature points.
The class supports bin accuracy (pixel accuracy) and sub-bin accuracy (sub-pixel accuracy).
The non-maximum-suppression search is implemented by a vertical list holding maps of horizontal array elements.
The performance depends on the number of elements inserted into the individual maps.
Thus, do not add data elements with negligible value.
It should be mentioned that the application of this class should be restricted to situations in which the entire filter response values do not exist already.
The performance boost comes with a simultaneous determination of filter responses and the insertion of possible candidates for maximum locations.
- Template Parameters
-
| T | The data type of the individual elements that are applied for the non-maximum-suppression search. |
template<typename T >
template<typename TFloat , unsigned int tSize, bool tFindMaximum,
PixelCenter tPixelCenter>
| NonMaximumSuppression::RefinementStatus Ocean::CV::NonMaximumSuppressionT< T >::determinePrecisePeakLocationIterativeNxN |
( |
const uint8_t * |
frame, |
|
|
const unsigned int |
width, |
|
|
const unsigned int |
height, |
|
|
const unsigned int |
framePaddingElements, |
|
|
const TFloat |
x, |
|
|
const TFloat |
y, |
|
|
TFloat & |
preciseX, |
|
|
TFloat & |
preciseY, |
|
|
const unsigned int |
maxIterations = 5u, |
|
|
const TFloat |
stepSize = TFloat(0.75), |
|
|
const TFloat |
convergenceThreshold = TFloat(0.01) |
|
) |
| |
|
static |
Determines the precise sub-pixel peak location by iteratively sampling image intensity values at sub-pixel positions.
The function uses bilinear interpolation to sample a tSize x tSize grid of intensity values around the current estimate, calls determinePrecisePeakLocationNxN() to find the sub-pixel offset, and iterates with decreasing step size until convergence.
The valid sampling range is [0, width - 1]x[0, height - 1] for PC_TOP_LEFT or [0, width]x[0, height] for PC_CENTER.
- Parameters
-
| frame | Pointer to the first pixel of the grayscale frame (single channel, uint8_t), must be valid |
| width | The width of the frame in pixels, with range [tSize, infinity) |
| height | The height of the frame in pixels, with range [tSize, infinity) |
| framePaddingElements | The number of padding elements at the end of each frame row, in elements, with range [0, infinity) |
| x | The horizontal position of the initial peak estimate, in the coordinate system defined by tPixelCenter |
| y | The vertical position of the initial peak estimate, in the coordinate system defined by tPixelCenter |
| preciseX | The resulting precise horizontal position, in the coordinate system defined by tPixelCenter |
| preciseY | The resulting precise vertical position, in the coordinate system defined by tPixelCenter |
| maxIterations | The maximum number of refinement iterations, with range [1, infinity) |
| stepSize | The initial step size for the sampling grid, with range (0, 1] |
| convergenceThreshold | The threshold for the pixel offset magnitude below which convergence is declared, with range (0, infinity) |
- Returns
- The refinement status
- Template Parameters
-
| TFloat | The floating point data type to be used for calculation, either 'float' or 'double' |
| tSize | The size of the sampling grid, must be odd and >= 3 |
| tFindMaximum | True, to find the intensity maximum; False, to find the intensity minimum |
| tPixelCenter | The pixel center to be used during interpolation, either 'PC_TOP_LEFT' or 'PC_CENTER' |
template<typename T >
template<typename TFloat , unsigned int tSize, bool tFindMaximum>
Determines the precise peak location in 2D space by fitting a quadratic surface via least-squares to a tSize x tSize grid of values.
Uses all tSize * tSize samples to fit F(x,y) = a + bx + cy + dx^2 + exy + fy^2 and solves for the peak of the fitted surface.
For a 3x3 grid this reduces to central differences; for larger grids the least-squares fit uses all samples for a more robust estimate.
The function validates that the fitted surface has the correct curvature (negative-definite Hessian for maximum, positive-definite for minimum).
- Parameters
-
| values | The grid values in row-major order, must have at least (tSize - 1) * valuesStrideElements + tSize elements |
| valuesStrideElements | The number of elements between the start of two consecutive rows, with range [tSize, infinity) |
| offsetX | The resulting horizontal offset of the peak from the grid center, in range (-1, 1) |
| offsetY | The resulting vertical offset of the peak from the grid center, in range (-1, 1) |
- Returns
- True, if the fit succeeded, the curvature is correct, and the offset is within range; False, if the surface is degenerate, has wrong curvature, or the offset is out of range
- Template Parameters
-
| TFloat | The floating point data type to be used for calculation, either 'float' or 'double' |
| tSize | The size of the sampling grid, must be odd and >= 3 |
| tFindMaximum | True, to find the maximum of the fitted surface; False, to find the minimum |