Automatic measurement of length of curved line segments


I’m trying to measure the length of line segments. Therefore I’m generating a segmented line and spline fit it.Then I’m overlaying geometrical forms (e.g. ellipses) to cut the line into parts. Is there any possibility to measure the line length of the line segments I’m generating through this automatically? I can save the generated line into the ROI manager but I haven’t figured out where to go from here.

I’ve noticed another issue: When I’m generating the line, add it to the ROI manager and I’m selecting it again via ROI I can choose Selection --> Line to Area. When copying that area and adding it to a new image it is not copying the full line. From time to time the line is not copied in it’s full width. Is there any possibility to copy the line as it is drawn?

Thanks for your help!

Hi you,

If you want to measure line segment, you don’t need to fit spline.
The coordinates of vertices are given with the getSelectionCoordinates() function.
From the array you can calculate the length of the segments.

For your second problem, I don’t understand why you would use the Line to Area function and I am not able to replicate your problem. If you want to draw a line at the same position in a new image, select the line in the ROI manager and on your new image use Edit/Draw.


getSelectionCoordinates(x, y);
for (i=0; i<x.length-1; i++){
print(x[i]+" "+y[i]); }

Maybe it’s getting clearer when I’m showing some example pictures.

At first I want to generate randomly oriented lines. This is something I don’t see any problems with:

Here I have a randomly oriented lines which is added to the ROI manager. I can read out its length.
Now I’m generating a pattern which I’m laying above the randomly generated lines and now I want to read out how long the separated line segments are.

In the example you can see the line is cut in 4 (the 5th place is due to the image size) places so I’m getting 5 (6) separated line segments and I want to know the length of each segment. It would be great to even find a way to handle the overlaps, otherwise I could work with some sort of skeleton and count the pixels.

The questions with Line to Area came up as I’m normally using more than one line so I wanted to separate them via the ROI manager to have less overlaps of lines.