# Find Maxmia sorted?

Tags: #<Tag:0x00007fb87e20eae8>

#1

Dear Forum,
does anyone know if the FindMaxima https://imagej.nih.gov/ij/developer/api/ij/plugin/filter/MaximumFinder.html
in some order (i.e. coordinates, from the brightes to the less brigt) or nor?

Have a nice day,
Emanuele

#2

@emartini you can have a look at the source code, within the `findMaxima(ip, tolerance, threshold, outputType, excludeOnEdges, isEDM)` method, where `getSortedMaxPoints` is called:

That method has a javadoc comment that says they’re sorted by value:

Or, instead of looking at the source code, you can simply test it with a small macro, for example:

``````// Create an empty image
newImage("Untitled", "8-bit black", 100, 100, 1);

// Create five spots with different intensities
makeOval(20, 20, 5, 5);
setForegroundColor(10, 10, 10);
run("Fill", "slice");
makeOval(75, 10, 5, 5);
setForegroundColor(50, 50, 50);
run("Fill", "slice");
makeOval(10, 75, 5, 5);
setForegroundColor(80, 80, 80);
run("Fill", "slice");
makeOval(70, 60, 5, 5);
setForegroundColor(120, 120, 120);
run("Fill", "slice");
makeOval(80, 80, 5, 5);
setForegroundColor(200, 200, 200);
run("Fill", "slice");
run("Select None");

// Blur a bit
run("Gaussian Blur...", "sigma=2");

// Let's get a list of the maxima
run("Find Maxima...", "noise=2 output=List");
``````

which will output the list of maxima sorted by intensity, starting with the highest intensity:

X Y
82 82
72 62
12 77
77 12
22 22