Python中通过threshold创建mask
【code】
import numpy as np
threshold=2
a=np.array([[1,2,3],[3,4,5]])
b=a>threshold
print("a="+str(a))
print("b="+str(b))
【result】
a=[[1 2 3] [3 4 5]] b=[[False False True] [ True True True]]
【code】
import numpy as np
threshold=2
a=np.array([[1,2,3],[3,4,5]])
b=a>threshold
print("a="+str(a))
print("b="+str(b))
【result】
a=[[1 2 3] [3 4 5]] b=[[False False True] [ True True True]]