Login  Register

Re: Changing ROI labels

Posted by lihong.zhan on Oct 06, 2017; 11:48pm
URL: http://imagej.273.s1.nabble.com/Changing-ROI-labels-tp5016316p5019515.html

Hi Damian,

I am guessing by this point you probably already found a way to add label to
ROI at different positions. Just in case there are others like myself
interested in the same topic, here is what I wrote that will put the label
on the upper left corner of ROIs.

Lihong

run("Colors...", "foreground=white background=black selection=yellow");
setFont("Serif", 24, "antiliased");
//set the label font size.
count=roiManager("count");
for (i=0; i<count; i++) {
roiManager("Select", i);
getSelectionBounds(x, y, width, height);
//Get the coordinates(x,y,) of the selected ROI[i].
//Returns the smallest rectangle that can completely contain the current
selection.
//x and y are the pixel coordinates of the upper left corner of the
rectangle.
drawString(i, x, y);
//write the index i on the image at coordinates x, y,;
roiManager("Select", i);
roiManager("Draw");
//draw a white outline of the ROI;
}



--
Sent from: http://imagej.1557.x6.nabble.com/

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html