Snippets

Dave Mason Example code to process all ROIs in ROI manager (https://forum.image.sc/t/help-to-update-imagej-code/27566)

You are viewing an old version of this snippet. View the current version.
Revised by Dave Mason df8cc2a
//-- Set up example
run("Close All");
roiManager("reset");

run("Blobs (25K)");
makePoint(73, 42, "small yellow hybrid");
roiManager("Add");
makePoint(138, 52, "small yellow hybrid");
roiManager("Add");
makePoint(100, 74, "small yellow hybrid");
roiManager("Add");
makePoint(183, 102, "small yellow hybrid");
roiManager("Add");


//-- get the number

nROI = roiManager("count");
for (i = 0; i < nROI; i++) {
	roiManager("select", i);
	
//-- Your code goes here as if you've selected the ROI

run("Measure");
Roi.getCoordinates(xpoints, ypoints);
x0=xpoints[0];
setResult("Xi",nResults-1, x0);
y0=ypoints[0];
setResult("Yi",nResults-1, y0);
x1=xpoints[xpoints.length-1];
setResult("Xf",nResults-1, x1);
y1=ypoints[ypoints.length-1];
setResult("Yf",nResults-1, y1);
d=sqrt((x1-x0)*(x1-x0)+(y1-y0)*(y1-y0));
setResult("Displacement",nResults-1, d);
updateResults;

	
}

HTTPS SSH

You can clone a snippet to your computer for local editing. Learn more.