// This macro uses the Find Maxima command to count // and mark cells in a selection. It assumes the cells // are darker than the background. Set the 'darkCells' // variable to false to work with cells that are lighter than // the background. Use the "Open Test Image" macro // to download a test image from the ImageJ website. var threshold = 30; var darkCells = true; macro "Count and Mark Cells [1]" { if (selectionType<0 || selectionType>4) exit("Area selection required"); setupUndo; autoUpdate(false); if (darkCells) light="light"; else light=""; run("Find Maxima...", "output=[Point Selection] "+light+" noise="+threshold); getSelectionCoordinates(x, y); n = x.length; if (darkCells) setColor("white"); else setColor("black"); setLineWidth(1); for (i=0; i