draw grid lines over an image in matplotlib

Viewed 26751

How can I draw regular grid lines over a tiff image? I want to draw regular square grids for each interval (say 100 by 100 pixels) over the image and save that with the drawings. I also need to overlay each grid id as '1','2',...at the middle of each grid box.

3 Answers

Let me just leave it here

def draw_grid(image, line_space=20):
    H, W = image.shape
    image[0:H:line_space] = 1
    image[:, 0:W:line_space] = 1
Related