The following example python code can be used to generate a virtual reference grid for the 20×20 grid spacing included in the GelMap Sample Pack. For use with correction using BigWarp, adjust image height and width to have as many boxes as are in your acquisition (+ some buffer on each side), then upscale the image in FIJI to approximately match the pixel size.
from PIL import Image, ImageDraw
# Set grid parameters
image_w = 200 #Image width (px)
image_h = 200 #Image height (px)
spacing = 20 #Spacing between intersections (starter pack = 20)
line_w = 8 #Line width (starter pack = 8)
def generate_grid_image(image_w, image_h, spacing, line_w):
# Create a new image with a white background
image = Image.new("L", (image_w, image_h), "white")
draw = ImageDraw.Draw(image)
# Draw horizontal lines
for y in range(0, image_h, spacing):
draw.line([(0, y), (image_w, y)], fill="black", width=line_w)
# Draw vertical lines
for x in range(0, image_w, spacing):
draw.line([(x, 0), (x, image_h)], fill="black", width=line_w)
return image
# Generate the grid image
grid_image = generate_grid_image(image_w, image_h, spacing, line_w)
# Save the image or display it
grid_image.save("grid_image.tif")
grid_image.show()
