Getting point coordinates from line selection

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

Getting point coordinates from line selection

IJperson
Hi everyone

I'm trying to get coordinates at every pixel along a line selection in a
macro.
I found this teasing paragraph, from a while back:

"ImageJ 1.41h will have an easy way to get the coordinates of points
along a line, spaced one pixel apart. This feature is not yet in the
v1.41h daily build but it does have the ability to display wide lines
using translucency, similar to the way the Straighten plugin works.

-wayne "

from here
http://imagej.588099.n2.nabble.com/Get-continuous-pixel-coordinates-from-a-line-ROI-td637663.html

Has such an easy method been implemented yet (I can't find it, but maybe
I'm looking in the wrong place)

Thanks
Andrew
Reply | Threaded
Open this post in threaded view
|

Re: Getting point coordinates from line selection

dpoburko
On 4/19/2011 2:43 AM, Andrew French wrote:
> Hi everyone
>
> I'm trying to get coordinates at every pixel along a line selection in
> a macro.
> I found this teasing paragraph, from a while back:
>
Hey Andrew,

  I think the code that you want is " getSelectionCoordinates(x, y); "

  The following code gives is an exaple of how it can be use in a
function in a macro to get the xy coordinates of a line selection:

function selectionLength() {

      getSelectionCoordinates(x, y);
      segments = newArray(x.length-1);
      lineLength =0;
      for (i=1; i<x.length; i++) {
          segments[i-1] =  sqrt( pow( (x[i-1] - x[i]),2) + pow( (y[i-1]
- y[i]),2) );
     lineLength = lineLength + segments[i-1];
      }
     return lineLength;
}

Damon

> "ImageJ 1.41h will have an easy way to get the coordinates of points
> along a line, spaced one pixel apart. This feature is not yet in the
> v1.41h daily build but it does have the ability to display wide lines
> using translucency, similar to the way the Straighten plugin works.
>
> -wayne "
>
> from here
> http://imagej.588099.n2.nabble.com/Get-continuous-pixel-coordinates-from-a-line-ROI-td637663.html
>
> Has such an easy method been implemented yet (I can't find it, but
> maybe I'm looking in the wrong place)
>
> Thanks
> Andrew
Reply | Threaded
Open this post in threaded view
|

Re: Getting point coordinates from line selection

Rasband, Wayne (NIH/NIMH) [E]
In reply to this post by IJperson
On Apr 19, 2011, at 5:43 AM, Andrew French wrote:

> Hi everyone
>
> I'm trying to get coordinates at every pixel along a line selection in a
> macro.
> I found this teasing paragraph, from a while back:
>
> "ImageJ 1.41h will have an easy way to get the coordinates of points
> along a line, spaced one pixel apart. This feature is not yet in the
> v1.41h daily build but it does have the ability to display wide lines
> using translucency, similar to the way the Straighten plugin works.
>
> -wayne "
>
> from here
> http://imagej.588099.n2.nabble.com/Get-continuous-pixel-coordinates-from-a-line-ROI-td637663.html
>
> Has such an easy method been implemented yet (I can't find it, but maybe
> I'm looking in the wrong place)

You can get the coordinates of points along a line selection at one pixel intervals using

   run("Fit Spline", "straighten");
   getSelectionCoordinates(x, y);

You can get the values along a line selection at one pixel intervals using

   values = getProfile();

-wayne
Reply | Threaded
Open this post in threaded view
|

Re: Getting point coordinates from line selection

IJperson
Thanks for the replies. I tried Wayne's method and it seems to work well.
Cheers
Andrew

On 20/04/2011 05:42, Rasband, Wayne (NIH/NIMH) [E] wrote:

> On Apr 19, 2011, at 5:43 AM, Andrew French wrote:
>
>> Hi everyone
>>
>> I'm trying to get coordinates at every pixel along a line selection in a
>> macro.
>> I found this teasing paragraph, from a while back:
>>
>> "ImageJ 1.41h will have an easy way to get the coordinates of points
>> along a line, spaced one pixel apart. This feature is not yet in the
>> v1.41h daily build but it does have the ability to display wide lines
>> using translucency, similar to the way the Straighten plugin works.
>>
>> -wayne "
>>
>> from here
>> http://imagej.588099.n2.nabble.com/Get-continuous-pixel-coordinates-from-a-line-ROI-td637663.html
>>
>> Has such an easy method been implemented yet (I can't find it, but maybe
>> I'm looking in the wrong place)
> You can get the coordinates of points along a line selection at one pixel intervals using
>
>     run("Fit Spline", "straighten");
>     getSelectionCoordinates(x, y);
>
> You can get the values along a line selection at one pixel intervals using
>
>     values = getProfile();
>
> -wayne
Reply | Threaded
Open this post in threaded view
|

Re: Getting point coordinates from line selection

Yuan
In reply to this post by Rasband, Wayne (NIH/NIMH) [E]
Hi,

I have the same problem of getting coordinates and pixel value for line selection. However, when I use 'Straight line' to mark my ROI and try the macro code

run("Fit Spline", "straighten");
getSelectionCoordinates(x, y);
values = getProfile();

ImageJ showed the message "Polygon or polyline selection required"

Does anyone How can I fix it? I use ImageJ 1.45s.Thank you.



Yuan