Reputation: 1536
I have a 3D numpy array [[[242,122,123],[111,30,12]]]
I want to create a mask for it. for the first array it would be condition 242 > 122+123. Is there a way to do it with numpy where condition? Something like mask[a > b+c] = 1
where a,b,c are the values from the array.
Upvotes: 0
Views: 966
Reputation: 231738
This is just a guess (as to what you want)
In [134]: M=np.array([[[242,122,123],[111,30,12]]])
In [135]: M.shape
Out[135]: (1, 2, 3)
In [136]: M[:,:,0]>(M[:,:,1]+M[:,:,2])
Out[136]: array([[False, True]], dtype=bool)
In [137]: M[_]
Out[137]: array([[111, 30, 12]])
Upvotes: 1