I have a Fiji macro which enables me to apply a hexagon grid to an image for sampling (it’s not my macro). I can change the size of the hexagons in the grid by changing the edge lengths in the macro. However, I now need to decrease the size of the hexagons now (below 500) whilst keeping the centre (centroid) of each hexagon in a fixed spot. This will obviously mean breaking up the grid, which is fine. I just need the x y coordinates to remain fixed. Is there a way to do this by adding to the code I have? Essentially I would like to start off with a hexagon grid, then decrease the sizes of the hexagons so it appears like there are multiple smaller hexagons inside each initial one.

Any help would be greatly appreciated as this is beyond my skill now.

```
l = 500; // length of hexagon side (pixels)
// hexagon geometry parameters
xIni = 1.0;
yIni = sqrt (3.0) / 2.0;
xSiz = xIni;
ySiz = yIni;
xDel = 3.0;
yDel = yIni;
xOff = 1.5; // offset for every other row of hexagons
// scale up to get desired size
xIni *= l;
yIni *= l;
xSiz *= l;
ySiz *= l;
xDel *= l;
yDel *= l;
xOff *= l;
getDimensions (width, height, dummy, dummy, dummy);
// loop over rows of hexagons
iOff = 0; // which staggered row of hexagons
y = yIni;
while (y + ySiz < height) {
// loop over hexagons in a row
x = xIni + (iOff % 2) * xOff;
while (x + xSiz < width) {
// build hexagonal ROI
x1 = x + xSiz;
y1 = y;
x2 = x + xSiz / 2.0;
y2 = y - ySiz;
x3 = x - xSiz / 2.0;
y3 = y - ySiz;
x4 = x - xSiz;
y4 = y;
x5 = x - xSiz / 2.0;
y5 = y + ySiz;
x6 = x + xSiz / 2.0;
y6 = y + ySiz;
makePolygon (x1, y1, x2, y2, x3, y3, x4, y4, x5, y5, x6, y6);
// add to ROI Manager
roiManager ("add");
x += xDel;
}
iOff++;
y += yDel;
}
// display all hexagonal ROIs`Preformatted text`
roiManager ("deselect");
roiManager ("show all");
run("Analyze Particles...", "include ");;
numROIs= roiManager("Count");
for (j=0; j<numROIs; j++)
{
imgID= getImageID();
roiManager("select",j);
run("Analyze Particles...", "include ");;
}
```

```
type or paste code here
```