/* This is the second draft of the macro. Needs a lot more documentation. v101 only marked the image. v102 adds reporting to the Log window To use, user chooses the Multi-point Tool to count objects. setTool("multipoint"); */ var tab = " \t "; var counter = 0; var fontSize = 18; //==================================================== macro "Reset Counter" { counter = 0; print("title \t #measurement \t count \t Xlocation \t Ylocation"); } //==================================================== macro "count, mark and log [q]" { if (selectionType != 10) exit("requires a few points clicked"); counter++; startcount = nResults(); run("Measure"); endcount = nResults(); counted = endcount - startcount; run("Convex Hull"); run("Fit Spline"); // optional color = ""; a = newArray(3); for (i=0; i<3; i++) { a[i] = round (128+(random()*128)); color = color + toHex(a[i]); } setColor(a[0], a[1], a[2]); Overlay.addSelection(color); run("Set Measurements...", "centroid redirect=None decimal=0"); run("Measure"); x = getResult("X", nResults()-1); y = getResult("Y", nResults()-1); toUnscaled(x, y); // Border on number setFont("SansSerif", fontSize+3); setColor(0,0,0); Overlay.drawString("#"+counter+": "+counted, x-fontSize-fontSize-1, y+3); // number same color as ROI setColor(a[0], a[1], a[2]); setFont("SansSerif", fontSize); Overlay.drawString("#"+counter+": "+counted, x-fontSize-fontSize, y); //Overlay.addSelection(color); run("Select None"); print(getTitle() + tab + counter + tab + counted + tab + round(x) + tab + round(y)); // selectWindow("Log"); }