I have 2 numpy arrays. One is a 3D integer array (image RGB values) with dimensions (988, 790, 3) and the other is a mask boolean array with the same shape. I want to use the mask to convert False values in the image array to black and leave true values as is.
I tried (image & mask) which appears to convert the entire image to black (or white) instead of just the False locations. I want to avoid loops for efficiency so looking for a numpy solution.
>Solution :
Since True and False values are treated as 1 and 0 respectively, you can simply use element-wise multiplication to get your desired result:
image * mask