I have a NumPy array of shape (100,100,3)
(an RGB image). I want to compare all 3-eleemnt tuples contained in the array for equality to produce array of booleans of shape (100,100)
.
Expected usage:
import numpy as np
arr = np.array([
[(1,2,3), (2,2,2), (1,2,3), ... ],
[(0,2,3), (2,2,2), (1,2,3), ... ],
...
])
bools = np.some_operation(arr, (1,2,3)
print(bools)
assert(bools == np.array([
[True, False, True, ...],
[False, False, True, ...],
...
])
I would like to avoid iterating over the whole array in Python code, since scalar access is not very fast in NumPy.
am I missing something?