I have a 3d numpy array. It's an array of 2d square images, all of the same size. my task is to block out a random square patch of the images (set all the pixel values to 0). I can figure out how to do it in the case where i just have 1 image as follows
x = np.random.randint(image_width - size)
y = np.random.randint(image_width - size)
image[x:x + size, y:y + size] = 0
where size is the size of the blocked out area. I'm not sure how to efficiently do this technique to an array of 2d images, where the blocked out patch is randomly generated for each one (not necessarily the same patch blocked out in each image in the array). I'm feeling a bit lost in all the new indexing tools I have to deal with (broadcasting, fancy indexing etc) and was wondering if there was a quick and simple way to do this thanks. My approach at the moment is to simply iterate over each image using a for loop, doing one image at a time but I wondered if numpy is powerful enough to somehow do them all in one fell swoop. I do realize that I need to use
x_array = np.random.randint(image_width - size, size=len(image_array))
y_array = np.random.randint(image_width - size, size=len(image_array))
at some point but I don't know where.