I have a numpy boolean 2D array that represents a grayscale image which is essentially an unfilled shape (triangle, square, circle) consisting of True for white pixels, and False for black pixels. I would like to add a black fill by modifying the white pixels to black pixels.
array([[True, True, True, False, False, False, False, False, True, True, True],
[True, True, True, False, True, True, True, False, True, True, True],
[True, True, True, False, True, True, True, False, True, True, True],
[True, True, True, False, True, True, True, False, True, True, True],
[True, True, True, False, False, False, False, False, True, True, True]])
(The 9 True values in a square in the middle of this array should become False.)
Is there a numpy slice method that will make this easy/fast? Something that I can modify all Trues anytime there's a False followed by a True until the next instance of a False?