I think I found a bug with the MaximumFinder class.
In empty images (all pixels to 0 or 1) it still finds 4 maxima, all of coordinates (0,0) !
It was messing up a pipeline in which I was detecting maxima in “partially” thresholded images*, which were eventually black when the threshold is too high.
*(“TO_ZERO” threshold of opencv that keeps initial pixel values above threshold, assign 0 value below)
Try it yourself (jython)
from ij.plugin.filter import MaximumFinder from ij import IJ # Create a blank image imp = IJ.createImage("Untitled", "8-bit white", 20, 20, 1) # white or black, -> find 4 peaks at 0,0 !? #imp = IJ.createImage("Untitled", "8-bit noise", 20, 20, 1) # -> this is fine # Detect maxima tolerance = 10 excludeOnEdge = False Polygon = MaximumFinder().getMaxima(imp.getProcessor(), tolerance, excludeOnEdge) # Print x,y of maxima for x,y in zip(Polygon.xpoints, Polygon.ypoints): print x,y
Related issue on GitHub