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]]

  

posted @ 2018-02-08 20:58  AI菌  阅读(2602)  评论(0编辑  收藏  举报