Login  Register

find all locations of the same pixel value

Posted by 周鑫 on Aug 14, 2012; 6:09am
URL: http://imagej.273.s1.nabble.com/calculating-DF-F-and-movement-correction-tp4999726p4999753.html

Dear all,

I want to find in one image all the locations which have the same pixel value.

currently I wrote a function for that:

=======================================

ArrayList<int[]> locations = new ArrayList<int[]>();
  for (int x=0; x<iproc.getWidth(); x++)
  {
   for(int y=0; y<iproc.getHeight(); y++)
   {
    if (iproc.getPixel(x, y) == pixelValue)
    {
     locations.add(new int[]{x,y});
    }
   }
  }
  return locations;

=======================================

but I wonder if there is something more smart, or build-in functions that can do the job quicker.

This is for me a basic operation, which will be done again and again. There must be more intelligent ways.

Many thanks, Xin



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