 # Average distance between two polylines in Fiji

Hello

Is there a plugin to measure the average distance between two polylines that runs in fiji?

Thanks
Pedro

Hi,

can you share an example image, or screenshot, to illustrate what your goal is?

Generally speaking, you can convert one line selection into a binary mask, then make a distance transform/map (see distance map here, or a well working version is part of the 3D Suite). The intensity now encodes the distance to the line ; further away=higher value. Now you compute the mean along your other line.

Be aware that ‘average distance’ is not necessarily symmetric: avgdist from all points in line A to line B can be different than from all points from line B from line A . Only minimum distance is unique afaik.

PS: Also interesting if you have a closed binary mask: Local Thickness Plugin.

Here follows one sample image with the two lines over it.
The idea is to measure the average distance of both lines.

Here is an example macro that does what @noreenw explained.

It will give you the mean minimum distance from line 1 to line 2 as a results table.
The plot shows the distance (in pixels) of line 1 from line 2 along line 1.

``````
// Have exactly two lines in the ROI manager

setBatchMode(true);
image=getTitle();

getDimensions(width, height, channels, slices, frames);

newImage("For Distance", "8-bit white", width, height, 1);

roiManager("Select", 1);
setForegroundColor(0, 0, 0);
run("Draw", "slice");
run("Exact Euclidean Distance Transform (3D)");

selectImage("EDT");
rename(image+"-EDT");

roiManager("Select", 0);
profile = getProfile();