Class LocalMinMaxFinder

java.lang.Object
imagingbook.common.image.LocalMinMaxFinder

public class LocalMinMaxFinder extends Object

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.

  • Constructor Details

    • LocalMinMaxFinder

      public LocalMinMaxFinder(float[][] fpixels, double threshold, int borderWidth)
      Constructor accepting a 2D data array of type float.
      Parameters:
      fpixels - the 2D data array
      threshold - the minimum difference between a center value and its 8 surrounding values to be accepted as a local extremum
      borderWidth - width of border margin to be ignored (> 0)
    • LocalMinMaxFinder

      public LocalMinMaxFinder(ImageProcessor ip, double threshold, int borderWidth)
      Constructor accepting an ImageProcessor instance. Color images are converted to scalar float values for extremum detection.
      Parameters:
      ip - the input image
      threshold - the minimum difference between a center value and its 8 surrounding values to be accepted as a local extremum
      borderWidth - width of border margin to be ignored
    • LocalMinMaxFinder

      Constructor accepting an ImageProcessor instance using default parameters.
      Parameters:
      ip - the input image
  • Method Details