Login  Register

Re: How to create a regular grid of rectangular ROI's?

Posted by Nathaniel Ryckman on Apr 07, 2011; 8:47pm
URL: http://imagej.273.s1.nabble.com/How-to-create-a-regular-grid-of-rectangular-ROI-s-tp3685056p3685059.html

Make a macro like this:

x = 0;
y = 0;
width = 40;
height = 40;
spacing = 10;

for(i = 1; i < numRect; i++)
{
  xOffset = xScalar * i + spacing;
  yOffset = yScalar * i;
 
  makeRectangle(x + xOffset, y + xOffset, width, height);

  run("To ROI Manager");
}

I didn't actually do the math, so you'll have to edit the numbers a little. The top-left corner of your image is x = 0 and y = 0.

Good luck!