Login  Register

Re: How do you label a line measurement with its length?

Posted by Krs5 on May 10, 2015; 3:36pm
URL: http://imagej.273.s1.nabble.com/How-do-you-label-a-line-measurement-with-its-length-tp5012782p5012801.html

Dear Nick,

See if the macro code below does what you have in mind. It assumes that your lines are stored in the ROI manager. All averages are also added to the manager. Use "show all" in the ROI manager to see the results. If you want to label at the end of the line and not near the centre delete the two line:
x2 = (x2-x1)/2 + x1;
y2 = (y2-y1)/2 + y1;


getPixelSize(unit, width, height, depth);
setFont("Sanserif", 12, "bold");
count=roiManager("count");
for (i=0; i<count ;i++){
 roiManager("select", i);
 getLine(x1, y1, x2, y2, lineWidth);
 x1b = x1 * width;
 y1b = y1 * height;
 x2b = x2 * width;
 y2b = y2 * height;
 Length = sqrt(pow(x2b-x1b, 2)+pow(y2b-y1b, 2));
 x2 = (x2-x1)/2 + x1;
 y2 = (y2-y1)/2 + y1;
 makeText(Length, x2, y2);
 roiManager("Add", "white");
}

Best wishes

Kees

Dr Ir K.R. Straatman
Senior Experimental Officer
Advanced Imaging Facility
University of Leicester
http://www2.le.ac.uk/colleges/medbiopsych/facilities-and-services/cbs/lite/aif


________________________________________
From: ImageJ Interest Group [[hidden email]] on behalf of lgxnjpr [[hidden email]]
Sent: 08 May 2015 17:09
To: [hidden email]
Subject: How do you label a line measurement with its length?

Hi,

I wish to make multiple measurements across an image, marking the line and
its length each time. I have been able to measure lines, and label them
(1,2,3... etc) but is there a way of quickly/automatically labeling the line
with its own measurement?

Any help would be much appreciated!

Thanks,
Nick



--
View this message in context: http://imagej.1557.x6.nabble.com/How-do-you-label-a-line-measurement-with-its-length-tp5012782.html
Sent from the ImageJ mailing list archive at Nabble.com.

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