x,y coordinates from plot profile

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

x,y coordinates from plot profile

AJBell
Dear List,

In a macro we produce an ROI (a single bacterium), generate a line that defines the spine of the ROI, and would like to highlight with either the point selection or generating another ROI, bright features along the spine.

To do this, we are plotting the spine using makeLine() then running getProfile() to get the intensity values (z values) as an array. using this array we can identify the points of interest.

However, we haven't been able to figure out how to work backwards from the intensity value (the y value in the plot profile) to the (x,y) coordinate of the pixel of interest. Does anyone know how we can do this, or have any suggestions? They would be greatly appreciated.

(It should be possible using geometry, since we have the starting and ending coordinates to define the line in the first place, but I think we are running into problems since the pixels are displayed as squares not points.)

Andrew Bell

Maurice Shock Medical Sciences Building
Department of Infection, Immunity and Inflammation
University of Leicester
University Road
Leicester
LE1 9HN

[hidden email]
Reply | Threaded
Open this post in threaded view
|

Re: x,y coordinates from plot profile

lechristophe
Hi Andrew,

Check this IJ mailing list conversation:

http://imagej.1557.n6.nabble.com/Correspondance-between-line-ROI-coordinates-on-an-image-2D-XY-and-along-its-profile-1D-P-td3682712.html

Cheers,

Christophe

On Mon, Mar 5, 2012 at 18:16, Andrew Bell <[hidden email]> wrote:

> Dear List,
>
> In a macro we produce an ROI (a single bacterium), generate a line that defines the spine of the ROI, and would like to highlight with either the point selection or generating another ROI, bright features along the spine.
>
> To do this, we are plotting the spine using makeLine() then running getProfile() to get the intensity values (z values) as an array. using this array we can identify the points of interest.
>
> However, we haven't been able to figure out how to work backwards from the intensity value (the y value in the plot profile) to the (x,y) coordinate of the pixel of interest. Does anyone know how we can do this, or have any suggestions? They would be greatly appreciated.
>
> (It should be possible using geometry, since we have the starting and ending coordinates to define the line in the first place, but I think we are running into problems since the pixels are displayed as squares not points.)
>
> Andrew Bell
>
> Maurice Shock Medical Sciences Building
> Department of Infection, Immunity and Inflammation
> University of Leicester
> University Road
> Leicester
> LE1 9HN
>
> [hidden email]
Reply | Threaded
Open this post in threaded view
|

Re: x,y coordinates from plot profile

AJBell
In reply to this post by AJBell
Hi Christophe,

Thanks for the link. I had a look at the suggestions, but unfortunately it wouldn't work for me: when I run fit spline and call plotProfile, I get a plot of 44 points, but calling getSelectionCoordinates returns 100.

Andrew

________________________________________
From: ImageJ Interest Group [[hidden email]] On Behalf Of Christophe Leterrier [[hidden email]]
Sent: 05 March 2012 17:42
To: [hidden email]
Subject: Re: x,y coordinates from plot profile

Hi Andrew,

Check this IJ mailing list conversation:

http://imagej.1557.n6.nabble.com/Correspondance-between-line-ROI-coordinates-on-an-image-2D-XY-and-along-its-profile-1D-P-td3682712.html

Cheers,

Christophe

On Mon, Mar 5, 2012 at 18:16, Andrew Bell <[hidden email]> wrote:

> Dear List,
>
> In a macro we produce an ROI (a single bacterium), generate a line that defines the spine of the ROI, and would like to highlight with either the point selection or generating another ROI, bright features along the spine.
>
> To do this, we are plotting the spine using makeLine() then running getProfile() to get the intensity values (z values) as an array. using this array we can identify the points of interest.
>
> However, we haven't been able to figure out how to work backwards from the intensity value (the y value in the plot profile) to the (x,y) coordinate of the pixel of interest. Does anyone know how we can do this, or have any suggestions? They would be greatly appreciated.
>
> (It should be possible using geometry, since we have the starting and ending coordinates to define the line in the first place, but I think we are running into problems since the pixels are displayed as squares not points.)
>
> Andrew Bell
>
> Maurice Shock Medical Sciences Building
> Department of Infection, Immunity and Inflammation
> University of Leicester
> University Road
> Leicester
> LE1 9HN
>
> [hidden email]
Reply | Threaded
Open this post in threaded view
|

Re: x,y coordinates from plot profile

AJBell
In reply to this post by AJBell
Solved.

It would have helped if I had read the entire exchange, as the solution was presented below. My appologies. Thank you for the help.

For future reference I have appended it below.

Andrew

Use the "straighten" option of "Fit Spline" to get one pixel spacing and the getSelectionCoordinates() macro function or getFloatPolygon() method to get the coordinates as two arrays. Here is a macro example:

  run("Fit Spline", "straighten");
  getSelectionCoordinates(x, y);
  x2=0; y2=0; distance=0;
  for (i=0; i<x.length; i++) {
      if (i>0) {
         dx = x[i] - x[i-1];
         dy = y[i] - y[i-1];
         distance = sqrt(dx*dx+dy*dy);
      }
      print(i, x[i], y[i], distance);
  }

And here is a JavaScript version:

  imp = IJ.getImage();
  IJ.run("Fit Spline", "straighten");
  roi = imp.getRoi();
  p = roi.getFloatPolygon();
  x2=0; y2=0; distance=0;
  for (i=0; i<p.npoints; i++) {
      if (i>0) {
         dx = p.xpoints[i] - p.xpoints[i-1];
         dy = p.ypoints[i] - p.ypoints[i-1];
         distance = Math.sqrt(dx*dx+dy*dy);
      }
      x = IJ.d2s(p.xpoints[i],2);
      y = IJ.d2s(p.ypoints[i],2);
      d = IJ.d2s(distance,2);
      print(i+" "+x+"  "+y+"  "+d);
  }

-wayne
 





> Hi Christophe,
>
> Thanks for the link. I had a look at the suggestions, but unfortunately it wouldn't work for me: when I run fit spline
> and call plotProfile, I get a plot of 44 points, but calling getSelectionCoordinates returns 100.
>
> Andrew
>
________________________________________
From: ImageJ Interest Group [[hidden email]] On Behalf Of Christophe Leterrier [[hidden email]]
Sent: 05 March 2012 17:42
To: [hidden email]
Subject: Re: x,y coordinates from plot profile

Hi Andrew,

Check this IJ mailing list conversation:

http://imagej.1557.n6.nabble.com/Correspondance-between-line-ROI-coordinates-on-an-image-2D-XY-and-along-its-profile-1D-P-td3682712.html

Cheers,

Christophe

On Mon, Mar 5, 2012 at 18:16, Andrew Bell <[hidden email]> wrote:

> Dear List,
>
> In a macro we produce an ROI (a single bacterium), generate a line that defines the spine of the ROI, and would like to highlight with either the point selection or generating another ROI, bright features along the spine.
>
> To do this, we are plotting the spine using makeLine() then running getProfile() to get the intensity values (z values) as an array. using this array we can identify the points of interest.
>
> However, we haven't been able to figure out how to work backwards from the intensity value (the y value in the plot profile) to the (x,y) coordinate of the pixel of interest. Does anyone know how we can do this, or have any suggestions? They would be greatly appreciated.
>
> (It should be possible using geometry, since we have the starting and ending coordinates to define the line in the first place, but I think we are running into problems since the pixels are displayed as squares not points.)
>
> Andrew Bell
>
> Maurice Shock Medical Sciences Building
> Department of Infection, Immunity and Inflammation
> University of Leicester
> University Road
> Leicester
> LE1 9HN
>
> [hidden email]
Reply | Threaded
Open this post in threaded view
|

Re: x,y coordinates from plot profile

lechristophe
In reply to this post by AJBell
What version of ImageJ are you running? There was a bug related to
that that was corrected around 1.46a-d

Christophe

On Tue, Mar 6, 2012 at 11:15, Andrew James Bell <[hidden email]> wrote:

> Hi Christophe,
>
> Thanks for the link. I had a look at the suggestions, but unfortunately it wouldn't work for me: when I run fit spline and call plotProfile, I get a plot of 44 points, but calling getSelectionCoordinates returns 100.
>
> Andrew
>
> ________________________________________
> From: ImageJ Interest Group [[hidden email]] On Behalf Of Christophe Leterrier [[hidden email]]
> Sent: 05 March 2012 17:42
> To: [hidden email]
> Subject: Re: x,y coordinates from plot profile
>
> Hi Andrew,
>
> Check this IJ mailing list conversation:
>
> http://imagej.1557.n6.nabble.com/Correspondance-between-line-ROI-coordinates-on-an-image-2D-XY-and-along-its-profile-1D-P-td3682712.html
>
> Cheers,
>
> Christophe
>
> On Mon, Mar 5, 2012 at 18:16, Andrew Bell <[hidden email]> wrote:
>> Dear List,
>>
>> In a macro we produce an ROI (a single bacterium), generate a line that defines the spine of the ROI, and would like to highlight with either the point selection or generating another ROI, bright features along the spine.
>>
>> To do this, we are plotting the spine using makeLine() then running getProfile() to get the intensity values (z values) as an array. using this array we can identify the points of interest.
>>
>> However, we haven't been able to figure out how to work backwards from the intensity value (the y value in the plot profile) to the (x,y) coordinate of the pixel of interest. Does anyone know how we can do this, or have any suggestions? They would be greatly appreciated.
>>
>> (It should be possible using geometry, since we have the starting and ending coordinates to define the line in the first place, but I think we are running into problems since the pixels are displayed as squares not points.)
>>
>> Andrew Bell
>>
>> Maurice Shock Medical Sciences Building
>> Department of Infection, Immunity and Inflammation
>> University of Leicester
>> University Road
>> Leicester
>> LE1 9HN
>>
>> [hidden email]
>
>