Login  Register

Re: Distance Between Lines, a plugin for ImageJ

Posted by Gabriel Landini on Aug 19, 2006; 11:43am
URL: http://imagej.273.s1.nabble.com/Distance-Between-Lines-a-plugin-for-ImageJ-tp3701802p3701803.html

On Thursday 17 August 2006 08:54, Birger Retterstøl Olaisen wrote:
> I have written a small plugin for ImageJ for measuring the average
> distance between two lines (which do not have to be straight).

Hi,

I haven't run the plugin, so apologies if the next part is not pertinent.
By looking at the source code, I think that there is another - perhaps
better - algorithm for this (I do not understand why one needs orthogonal
points) and it should work for lines in any orientation without the need of a
reference.

Get all the coordinates of line 1
Get all the coordinates of line 2
For each point in line 1{
 Calculate (using Pythagoras theorem) the distance to every point in line 2
 Keep the minimum of those distances in an array.
}

The Minimum of those minima is the minimum thickness.
The Maximum of those minima is the maximum thickness.
The Average of those minima is the average thickness.

One can speed that up by using the squares of the distances, thus saving one
square root (which tends to be slow) per test and calculating the square root
the the minimum after each cycle (i.e. the one you keep).

I hope it helps.

Gabriel