I have a Boolean mask (i.e. mask1) in a Numpy array. Its shape its as follows:
Then, I have the following code to extract the x and y coordinates of all the pixels within that mask
xy_coords = np.flip(np.column_stack(np.where(mask1 > 0)), axis=1)#getting coordinates of pixels within the mask
For my application, I need to reconstruct a new image using these coordinates (so the new image has to have the shape of the mask). I thought that this could be done with a simple for loop as follows:
for y in xy_coords[:,0]:
for x in xy_coords[:,1]:
new_image[x][y] = 1 #(or any other value)
However, the reconstructed new_image has a square shape and not the shape of the original mask.
Can anyone see what I am doing wrong and help me on what should I do?
Thanks heaps!

