Shortest distance between magic wand selections

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

Shortest distance between magic wand selections

Lasse
Hi all you smart people!

When I have to magic wand selections in an image, and I would like to find the shortest distance between these two selections. How would you approach this problem?

Thanks in advance!

/Lasse
Reply | Threaded
Open this post in threaded view
|

Re: Shortest distance between magic wand selections

Michael Schmid
Hi Lasse,

here is one possibility:
- create selection 1
- Edit>Selection>Create Mask
- select the original image and create selection 2
- Edit>Selection>Create Mask (this goes to the same mask)
- Process>Binary>Voronoi
- Threshold between 1 and the maximum (the line appears red)
- Edit>Selection>Create Selection
- Measure (make sure you have 'Min&Max' enabled in 'Set Measurements')
The distance is twice the Min value in the result (in pixels).

For slightly better accuracy, or if the distance can be larger than 510 pixels, select '32-bit' as output type of EDM, etc. in Process>Binary>Options.

Michael
________________________________________________________________
On Jul 24, 2012, at 09:13, Lasse wrote:

> Hi all you smart people!
>
> When I have to magic wand selections in an image, and I would like to find
> the shortest distance between these two selections. How would you approach
> this problem?
>
> Thanks in advance!
>
> /Lasse
>
>
>
> --
> View this message in context: http://imagej.1557.n6.nabble.com/Shortest-distance-between-magic-wand-selections-tp4999539.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
Reply | Threaded
Open this post in threaded view
|

Re: Shortest distance between magic wand selections

Cammer, Michael
In reply to this post by Lasse
This is an inelegant approach, but one we implemented years ago when we wanted to measure gold particles' shortest distances to a membrane.

We had the xy locations of each gold particle in an array and calculated for each particle every distance to the membrane and sorted for the shortest.  While this was a n squared brute force approach, computers are fast enough that it worked fine.  Initially we used the array function in Excel but then rewrote it as a macro in NIH-Image.

In this case, there would be two arrays, each one containing the XY locations of the edge of the magic wand selection.  Calculate all distances of perimeter points and sort for the shortest.  Certainly not elegant, but it will find the closest two points on the opposed perimeters.

-Michael C.

-----Original Message-----
From: ImageJ Interest Group [mailto:[hidden email]] On Behalf Of Lasse
Sent: Tuesday, July 24, 2012 3:14 AM
To: [hidden email]
Subject: Shortest distance between magic wand selections

Hi all you smart people!

When I have to magic wand selections in an image, and I would like to find the shortest distance between these two selections. How would you approach this problem?

Thanks in advance!

/Lasse



--
View this message in context: http://imagej.1557.n6.nabble.com/Shortest-distance-between-magic-wand-selections-tp4999539.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
Reply | Threaded
Open this post in threaded view
|

Re: Shortest distance between magic wand selections

Lasse
In reply to this post by Michael Schmid
Great, Thanks - you were a lot of help!!