How to get a new label column in Result table based on ROI measurements

Hi,
Say I have an image with defined ROIs. I want to generate a new label column in the result table that indicates if the particle is “round” (circularity = 0.6-1.0), “irregular” (circularity = 0.4-0.6) or “elongated” (circularity = 0.0-0.4). And, if possible, visualize these labels as an overlay in the original image.

Thanks.

LeeRoiSet_Example1.zip (1.1 KB)

Hi @insertsk8,

Does something like the below work?

It adds a column to the results table with the label and changes the colour of the ROI depending on if your conditions for each class are met.

roiManager("Deselect");
run("Set Measurements...", "shape redirect=None decimal=3");
roiManager("Measure");
circ = Table.getColumn("Circ.");
setResult("Label", 1, 1);

for (i = 0; i < circ.length; i++){
	value = circ[i];
	if (value >= 0.6){
		setResult("Label", i, "Round");
		roiManager("Select", i);
		roiManager("Set Color", "red");
		roiManager("Set Line Width", 2);
	}
	if ((value >= 0.4) && (value < 0.6 )){
		setResult("Label", i, "Irregular");
		roiManager("Select", i);
		roiManager("Set Color", "orange");
		roiManager("Set Line Width", 2);
	}
	if (value < 0.4){
		setResult("Label", i, "Elongated");
		roiManager("Select", i);
		roiManager("Set Color", "yellow");
		roiManager("Set Line Width", 2);
	}
}

Yes!! That’s more than enough. Thanks a million.

Lee

1 Like