Snippets

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

Created by Dave Mason last modified
//-- Set up example
run("Close All");
roiManager("reset");

run("Blobs (25K)");
makeLine(74, 59, 161, 89);
roiManager("Add");
makeLine(72, 157, 179, 124);
roiManager("Add");
makeLine(141, 215, 208, 213);
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",i, x0);
y0=ypoints[0];
setResult("Yi",i, y0);
x1=xpoints[xpoints.length-1];
setResult("Xf",i, x1);
y1=ypoints[ypoints.length-1];
setResult("Yf",i, y1);
d=sqrt((x1-x0)*(x1-x0)+(y1-y0)*(y1-y0));
setResult("Displacement",i, d);
updateResults;
	
}
run("Select None");

Comments (0)