Distance Between Lines, a plugin for ImageJ

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Distance Between Lines, a plugin for ImageJ

birgerro
I have written a small plugin for ImageJ for measuring the average
distance between two lines (which do not have to be straight). I used
this plugin to measure the average width of screen-printed metallic
lines for solar cells, and I thought that it might be interesting for
other people also, if nothing else then as an example of plugin
programming. The plugin is a bit rough, so any ideas to make it more
user friendly would be appreciated.

The way the plugin is suposed to work, is this:

1) First you need to set the scale from the images by measuring a known
length (calibration sample) with

        Analyze->Set Scale...

2) Then you load a image you want to measure into ImageJ

3) Start the plugin with (the name depends on where you have installed
the plugin)

        Plugins->Distance Between Polylines

    A popup giving instructions should appear.

4) As per the instructions in the popup, first select the straight line
selection tool in the tool window, and draw a line along the finger you
want to measure. Then press [Enter].
        Sometimes ImageJ has a problem with focusing the right window, so if
the message in the popup doesn't change at this point, you have to make
the image window active again, and press [Enter] once more.

5) Select one of the line selection tools (straight line, segmented
line or freehand) and draw a line along one edge of the finger. Then
press [Enter] again.

6) Draw a line along the other edge of the finger, and press [Enter]
again.

7) The average distance between the drawn lines is shown in the
instruction popup, and also in the Average distances popup.

If you want any of the drawn lines to appear on the image, you can use
Edit->Draw before pressing [Enter] after drawing a line. You probably
also should save the image under a new name.

---
With regards,
Birger Retterstøl Olaisen
PhD-student, Institute for Energy Technology




Distance_Between_Polylines.java (12K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Distance Between Lines, a plugin for ImageJ

Gabriel Landini
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
Reply | Threaded
Open this post in threaded view
|

Re: Distance Between Lines, a plugin for ImageJ

Michael Cammer
A while back (using NIH-Image) I wrote a macro to find the minimum
distances between the edges of multiple irregular shaped objects by taking
all the edge points of each object and using (x1 - x0) ^ 2 + (y1 - y0) ^ 2
for every pair of points.  It worked fine and computers are fast, so even
in NIH-Image it only took seconds for a lot of objects.
-mc


> 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
>


_________________________________________
Michael Cammer
Analytical Imaging Facility and
Dept. ASB Biophotonics Innovation Laboratory
Albert Einstein College of Medicine
1300 Morris Park Avenue, Bronx, NY  10461
718-430-2890  Fax 718-430-8996
work:  http://www.aecom.yu.edu/aif/
personal:  http://coxcammer.com/