Login  Register

Re: Coordinates of Maximum

Posted by Rasband, Wayne (NIH/NIMH) [E] on Apr 26, 2014; 2:20pm
URL: http://imagej.273.s1.nabble.com/Coordinates-of-Maximum-tp5007427p5007457.html

On Apr 25, 2014, at 7:38 AM, Kenton Arkill wrote:

> Hi
> I have an area of an image for which there is a maximum value within that
> area (i.e. the max value if I "measure"). What is the most efficient way of
> getting the coordinates in in the macro language? I have 10s of thousands
> to do. The 'find maxima' does not always find one (sometimes more,
> sometimes less). It is difficult to set the noise tolerance to always get
> one.

Use the Process>Find Maxima command and set "Nose tolerance" to 99999. Here is a macro example:

  run("Cell Colony (31K)");
  run("Invert");
  run("Find Maxima...", "noise=99999 output=[Point Selection]");
  getSelectionBounds(x,y,width,height);
  print("coordinates="+x+","+y);
  print("value="+getPixel(x,y));

And here is a JavaScript example:

  imp = IJ.openImage("http://imagej.nih.gov/ij/images/Cell_Colony.jpg");
  ip = imp.getProcessor();
  ip.invert();
  mf = new MaximumFinder();
  p = mf.getMaxima(ip,99999,false)
  print("coordinates="+p.xpoints[0]+","+p.ypoints[0]);
  print("value="+ip.getPixel(p.xpoints[0],p.ypoints[0]));

-wayne


> I could get the value and search the area for it pixel by pixel but that
> seems a slow workaround.
> Any ideas welcome.
> Regards
> Kenton

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