Subtract 2 Numpy Arrays With Condition
I have two Numpy arrays which look like this: a = [[ [1,2,3], [4,5,6] ], [ [7,8,9], [10,11,12] ]] b = [[ [1,1,1], [0,0,0] ], [ [3,3,3], [4,4,4] ]] I want to perform c
Solution 1:
Use np.where
>>> c = np.where(np.array(b)>0, 255, a)
>>> c
array([[[255, 255, 255],
[ 4, 5, 6]],
[[255, 255, 255],
[255, 255, 255]]])
Btw. there is no subtracting happpening here; maybe change the title of your question.
Post a Comment for "Subtract 2 Numpy Arrays With Condition"