I have three numpy arrays: A, B, and C. I have to extract '1' that is common (pixel wise) to any two of the given arrays, and set all other elements as 0.
import numpy as np
A = np.array([[1,0,0,0,0],
[1,0,0,0,0],
[1,0,0,0,0]])
B = np.array([[1,1,1,1,1],
[1,1,1,1,1],
[1,1,1,1,1]])
C = np.array([[0,0,0,0,1],
[0,0,0,0,1],
[0,0,0,0,1]])
The expected answer would be:
result = np.array([[1,0,0,0,1],
[1,0,0,0,1],
[1,0,0,0,1]])
How can I do it using Numpy/Scipy? A faster performance is necessary since in my real problem, the number of arrays are 50s and the size of each array is (3000, 3000), and I have to extract the '1' if common to 30 arrays.