How do I get the pixel coordinate with minimum value?? please help!

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

How do I get the pixel coordinate with minimum value?? please help!

TLowe
I'm at my wits end. I have the following routine which gives me a list of pixel values along the line drawn. HOW DO I GET THE PIXEL COORDINATES OF THE PIXEL WITH THE LOWEST VALUE? It's been a few days now and I'm no further to an answer. If you have done this, or know how, please, please would you send me an update to the following code?

//setTool("line");
makeLine(828, 410, 674, 626);
  run("Clear Results");
  profile = getProfile();
  for (i=0; i<profile.length; i++)
      setResult("Value", i, profile[i]);
  updateResults;
Tom Lowe
Chemical Technician
Eastman Kodak
Reply | Threaded
Open this post in threaded view
|

Re: How do I get the pixel coordinate with minimum value?? please help!

Gabriel Landini
On Saturday 30 Aug 2014 16:28:53 you wrote:
> I'm at my wits end. I have the following routine which gives me a list of
> pixel values along the line drawn. HOW DO I GET THE PIXEL COORDINATES OF THE
> PIXEL WITH THE LOWEST VALUE? It's been a few days now and I'm no further to
> an answer.

There is no guarantee that there is a lowest pixel value.

Not sure this is the best way, but you can get the coordinates of the
interpolated line (otherwise a line selection has only 2 coordinates):

makeLine(828, 410, 674, 626);
run("Interpolate", "interval=1 adjust");
getSelectionCoordinates(cx,cy);
  run("Clear Results");
  profile = getProfile();
  for (i=0; i<profile.length; i++){
      setResult("Value", i, profile[i]);
      setResult("x", i,cx[i]);
      setResult("y", i,cy[i]);
  }
  updateResults;

There are no details/documentation on the "adjust" option in the interpolate
command, maybe it is not needed.
Regards

Gabriel

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
|

Re: How do I get the pixel coordinate with minimum value?? please help!

Cammer, Michael
In reply to this post by TLowe
Keep in mind that  interpolation, which is needed to define pixels between the endpoints of vertices in straight line segments, may return fractional pixel locations and, therefore, the pixel values returned may not be discrete but a combination of neighboring pixels.  For most biological applications, this won't significantly change the answer, but perhaps someone else could chime in with a reminder how to turn off this feature or maybe you could just make each points[i] = round(points[i]) if this is a concern, but then the pixel location my be off by 1.
Regards,
Michael

//  By simply iterating on a list of coordinates, this macro prints the location of the minimum pixel value and its location.
//  If there are multiple pixel locations with the same minimum, only the last found location is printed.
  run("Interpolate", "interval=1");
  getSelectionCoordinates(xpoints, ypoints);
  min = 999999999999999999999999;
  for (i=0; i<xpoints.length; i++) {
    if ( getPixel(xpoints[i], ypoints[i]) < min )  {
      min = getPixel(xpoints[i], ypoints[i]);    
      x = xpoints[i];
      y = ypoints[i];  
    } // if
  }  // for i
  print("x \t y \t value");
  print (x + " \t " + y + " \t " + min);
  selectWindow("Log");



_________________________________________
Michael Cammer, Optical Microscopy Specialist
http://ocs.med.nyu.edu/microscopy
Lab: (212) 263-3208  Cell: (914) 309-3270

________________________________________
From: ImageJ Interest Group [[hidden email]] on behalf of TLowe [[hidden email]]
Sent: Saturday, August 30, 2014 7:28 PM
To: [hidden email]
Subject: How do I get the pixel coordinate with minimum value?? please help!

I'm at my wits end. I have the following routine which gives me a list of
pixel values along the line drawn. HOW DO I GET THE PIXEL COORDINATES OF THE
PIXEL WITH THE LOWEST VALUE? It's been a few days now and I'm no further to
an answer. If you have done this, or know how, please, please would you send
me an update to the following code?

//setTool("line");
makeLine(828, 410, 674, 626);
  run("Clear Results");
  profile = getProfile();
  for (i=0; i<profile.length; i++)
      setResult("Value", i, profile[i]);
  updateResults;



-----
Tom Lowe
Chemical Technician
Eastman Kodak
--
View this message in context: http://imagej.1557.x6.nabble.com/How-do-I-get-the-pixel-coordinate-with-minimum-value-please-help-tp5009425.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: How do I get the pixel coordinate with minimum value?? please help!

Cammer, Michael
actually, the first location is reported...

_________________________________________
Michael Cammer, Optical Microscopy Specialist
http://ocs.med.nyu.edu/microscopy
Lab: (212) 263-3208  Cell: (914) 309-3270

________________________________________
From: ImageJ Interest Group [[hidden email]] on behalf of Cammer, Michael [[hidden email]]
Sent: Saturday, August 30, 2014 8:43 PM
To: [hidden email]
Subject: Re: How do I get the pixel coordinate with minimum value?? please help!

Keep in mind that  interpolation, which is needed to define pixels between the endpoints of vertices in straight line segments, may return fractional pixel locations and, therefore, the pixel values returned may not be discrete but a combination of neighboring pixels.  For most biological applications, this won't significantly change the answer, but perhaps someone else could chime in with a reminder how to turn off this feature or maybe you could just make each points[i] = round(points[i]) if this is a concern, but then the pixel location my be off by 1.
Regards,
Michael

//  By simply iterating on a list of coordinates, this macro prints the location of the minimum pixel value and its location.
//  If there are multiple pixel locations with the same minimum, only the last found location is printed.
  run("Interpolate", "interval=1");
  getSelectionCoordinates(xpoints, ypoints);
  min = 999999999999999999999999;
  for (i=0; i<xpoints.length; i++) {
    if ( getPixel(xpoints[i], ypoints[i]) < min )  {
      min = getPixel(xpoints[i], ypoints[i]);
      x = xpoints[i];
      y = ypoints[i];
    } // if
  }  // for i
  print("x \t y \t value");
  print (x + " \t " + y + " \t " + min);
  selectWindow("Log");



_________________________________________
Michael Cammer, Optical Microscopy Specialist
http://ocs.med.nyu.edu/microscopy
Lab: (212) 263-3208  Cell: (914) 309-3270

________________________________________
From: ImageJ Interest Group [[hidden email]] on behalf of TLowe [[hidden email]]
Sent: Saturday, August 30, 2014 7:28 PM
To: [hidden email]
Subject: How do I get the pixel coordinate with minimum value?? please help!

I'm at my wits end. I have the following routine which gives me a list of
pixel values along the line drawn. HOW DO I GET THE PIXEL COORDINATES OF THE
PIXEL WITH THE LOWEST VALUE? It's been a few days now and I'm no further to
an answer. If you have done this, or know how, please, please would you send
me an update to the following code?

//setTool("line");
makeLine(828, 410, 674, 626);
  run("Clear Results");
  profile = getProfile();
  for (i=0; i<profile.length; i++)
      setResult("Value", i, profile[i]);
  updateResults;



-----
Tom Lowe
Chemical Technician
Eastman Kodak
--
View this message in context: http://imagej.1557.x6.nabble.com/How-do-I-get-the-pixel-coordinate-with-minimum-value-please-help-tp5009425.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

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
|

Re: How do I get the pixel coordinate with minimum value?? please help!

Jan Eglinger
In reply to this post by Gabriel Landini
Hi all,

On 31.08.2014, 2:19 AM, Gabriel Landini wrote:
> run("Interpolate", "interval=1 adjust");
>  [...]
> There are no details/documentation on the "adjust" option in the interpolate
> command, maybe it is not needed.

In the changelog for 1.49e (2 August 2014), it reads:

 >> Thanks to Norbert Vischer, added an "Adjust interval to match" option
 >> to the Edit>Selection>Interpolate dialog. This option adjusts the
 >> interval so that the steps between the first and last point are
 >> equidistant.

Jan

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
|

Re: How do I get the pixel coordinate with minimum value?? please help!

Gabriel Landini
On Monday 01 Sep 2014 10:26:46 Jan Eglinger wrote:
> On 31.08.2014, 2:19 AM, Gabriel Landini wrote:
> > There are no details/documentation on the "adjust" option in the
> > interpolate command, maybe it is not needed.
 
> In the changelog for 1.49e (2 August 2014), it reads:
>  >> Thanks to Norbert Vischer, added an "Adjust interval to match" option
>  >> to the Edit>Selection>Interpolate dialog. This option adjusts the
>  >> interval so that the steps between the first and last point are
>  >> equidistant.

Thanks Jan,
I looked in the user guide, which is excellent, but it had the old version of
the command. Now I realise that this is quite a new feature and it will
probably be included in some future revision.

In the context of OP perhaps the option is better not included and the
addressing of each pixel in the line can be obtained by rounding the
interpolated coordinates?

Thanks again
Gabriel

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
|

Re: How do I get the pixel coordinate with minimum value?? please help!

ctrueden
Hi Gabriel,

> I looked in the user guide, which is excellent, but it had the old
> version of the command. Now I realise that this is quite a new feature
> and it will probably be included in some future revision.

Note that the ImageJ manual is open source:

https://github.com/tferr/IJ-guide

Anyone can contribute changes by filing a pull request.

Regards,
Curtis



On Mon, Sep 1, 2014 at 3:36 AM, Gabriel Landini <[hidden email]>
wrote:

> On Monday 01 Sep 2014 10:26:46 Jan Eglinger wrote:
> > On 31.08.2014, 2:19 AM, Gabriel Landini wrote:
> > > There are no details/documentation on the "adjust" option in the
> > > interpolate command, maybe it is not needed.
>
> > In the changelog for 1.49e (2 August 2014), it reads:
> >  >> Thanks to Norbert Vischer, added an "Adjust interval to match" option
> >  >> to the Edit>Selection>Interpolate dialog. This option adjusts the
> >  >> interval so that the steps between the first and last point are
> >  >> equidistant.
>
> Thanks Jan,
> I looked in the user guide, which is excellent, but it had the old version
> of
> the command. Now I realise that this is quite a new feature and it will
> probably be included in some future revision.
>
> In the context of OP perhaps the option is better not included and the
> addressing of each pixel in the line can be obtained by rounding the
> interpolated coordinates?
>
> Thanks again
> Gabriel
>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html