irregular ROIs

Posted by Tony Shepherd on
URL: http://imagej.273.s1.nabble.com/irregular-ROIs-tp3701774.html

can anyone tell me how to loop over an irregular (polygonal) ROI ?

I tried taking a control loop from the tutorial called Inverter_ (pasted below)

At the moment it only seems to loop over the bounding rectangle.

Thanks,

Tony.
..............................................

public void run(ImageProcessor ip) {
   byte[] pixels = (byte[])ip.getPixels();
   int width = ip.getWidth();
   Rectangle r = ip.getRoi();

   int offset, i;

   for (int y=r.y; y<(r.y+r.height); y++) {
      offset = y*width;
      for (int x=r.x; x<(r.x+r.width); x++) {
         i = offset + x;
         pixels[i] = (byte)(255-pixels[i]);
      }
   }
}