Like the title says, I want to compare two sitk arrays that have 1s and 0s as elements, and create a 3rd array that has 1s for where both arrays have 1 and 0s for any other cases. The arrays are the same size and are 3 dimensional, but is there a more efficient way to do this than iterating through them with nested for-loops?
import numpy as np
a = np.random.randint(low=0, high=2, size=(2,3,4), dtype=np.int)
print(a)
b = np.random.randint(low=0, high=2, size=(2,3,4), dtype=np.int)
print(b)
c = np.logical_and(a,b).astype(int)
print(c)
Is that what you're looking for?