Provides methods for detecting local maxima or minima in images or 2D data arrays. A local maximum (minimum) is
defined as a pixel position whose value is larger (smaller) than all its eight neighboring values. The detection is
controlled by a 'threshold' parameter specifying the minimum difference between the center value and the surrounding
values. There is also a 'borderWidth' parameter specifying the outer image margins to be ignored. This implementation
deliberately provides separate methods getMaxima(int)
and getMinima(int)
for detecting maxima and
minim, respectively. An alternative would be to have only one method and invert the data to obtain the other, but
inversion of float-data is not well defined and we wanted the original data values preserved with the returned point
sets. (This may change eventually.)
Note that this form of local extremum detection is simple but may fail on ridge points or locally flat spots. See
MaximumFinder
for a more robust (but also more complicated) implementation.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic class
A 2D point with integer coordinates and a score value (LocalMinMaxFinder.ExtremalPoint.q
) attached. -
Constructor Summary
ConstructorsConstructorDescriptionLocalMinMaxFinder
(float[][] fpixels, double threshold, int borderWidth) Constructor accepting a 2D data array of type float.Constructor accepting anImageProcessor
instance using default parameters.LocalMinMaxFinder
(ImageProcessor ip, double threshold, int borderWidth) Constructor accepting anImageProcessor
instance. -
Method Summary
Modifier and TypeMethodDescriptiongetMaxima
(int maxCount) Returns the detected local maxima as an array of typeLocalMinMaxFinder.ExtremalPoint
.getMinima
(int maxCount) Returns the detected local minima as an array of typeLocalMinMaxFinder.ExtremalPoint
.
-
Constructor Details
-
LocalMinMaxFinder
Constructor accepting a 2D data array of type float.- Parameters:
fpixels
- the 2D data arraythreshold
- the minimum difference between a center value and its 8 surrounding values to be accepted as a local extremumborderWidth
- width of border margin to be ignored (> 0)
-
LocalMinMaxFinder
Constructor accepting anImageProcessor
instance. Color images are converted to scalar float values for extremum detection.- Parameters:
ip
- the input imagethreshold
- the minimum difference between a center value and its 8 surrounding values to be accepted as a local extremumborderWidth
- width of border margin to be ignored
-
LocalMinMaxFinder
Constructor accepting anImageProcessor
instance using default parameters.- Parameters:
ip
- the input image
-
-
Method Details
-
getMaxima
Returns the detected local maxima as an array of typeLocalMinMaxFinder.ExtremalPoint
. The resulting array is sorted such that the position with the maximum score value (LocalMinMaxFinder.ExtremalPoint.q
) comes first. The array is never larger than the specified count.- Parameters:
maxCount
- the maximum number of extrema to search for- Returns:
- a sorted array of
LocalMinMaxFinder.ExtremalPoint
instances
-
getMinima
Returns the detected local minima as an array of typeLocalMinMaxFinder.ExtremalPoint
. The resulting array is sorted such that the position with the minimum score value (LocalMinMaxFinder.ExtremalPoint.q
) comes first. The array is never larger than the specified count.- Parameters:
maxCount
- the maximum number of extrema to search for- Returns:
- a sorted array of
LocalMinMaxFinder.ExtremalPoint
instances
-