No line centroid coordinates from getValue but from Result table

when I try to get the centroid coordinates for a line ROI using getValue(“X” ) (or (“Y”), I get the image centroid coordinates instead. However, the results table shows the correct values. Looks like a bug?
The macro below demonstrates the issue.
I am using an up to date Fiji (ImageJ 1.53c99).

roiManager("reset");
run("Close All");

if (isOpen("Results")){
	selectWindow("Results");
	run("Close");
}	

if (isOpen("Log")){
	selectWindow("Log");
	run("Close");
}

newImage("Untitled", "8-bit black", 250, 250, 1);

// add 4 lines and 3 different shapes to the ROI manager
makeLine(24, 22, 104, 85);
roiManager("Add");
makeLine(162, 97, 226, 34);
roiManager("Add");
makeLine(34, 159, 27, 228);
roiManager("Add");
makeLine(190, 210, 129, 179);
roiManager("Add");
makeRectangle(27, 98, 44, 39);
roiManager("Add");
makeOval(102, 190, 43, 50);
roiManager("Add");
makePolygon(166,123,185,180,221,165,208,122);
roiManager("Add");

//prepare log winow
    print ("X               Y               Angle");
    print ("---------------------------------------");

for (i = 0; i < roiManager("count"); i++) {
	roiManager("select", i);
    x = getValue("X");
    y = getValue("Y");
    a = getValue("Angle");
    print (x+"          "+y+"          "+a);
	
	/*
	 * this produces the same output:
     * 
	 * List.setMeasurements;
     * x = List.getValue("X");
     * y = List.getValue("Y");
     * ang = List.getValue("Angle");
     */
}
roiManager("Deselect");
roiManager("Measure");
roiManager("Show all with labels");


exit ("Compare X and Y in the log window and the results table. For the lines (elements 1-4), \n"
	+"the log window actually shows the centroid coordiantes of the image and not\n"
	+"of the line selection\n"
	+"ImageJ version: "+IJ.getFullVersion);

1 Like

This bug is fixed in the ImageJ 1.53g62 daily build.

3 Likes