Login  Register

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

Posted by Cammer, Michael on Aug 31, 2014; 3:53pm
URL: http://imagej.273.s1.nabble.com/How-do-I-get-the-pixel-coordinate-with-minimum-value-please-help-tp5009425p5009430.html

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