如何使用Python中的threshold函数来生成mask?
- 内容介绍
- 文章标签
- 相关推荐
本文共计177个文字,预计阅读时间需要1分钟。
我将对原文进行简化改写,并确保不超过100个字:
pythonimport numpy as npthreshold=2a=np.array([[1, 2, 3], [3, 4, 5]])b=a > thresholdprint(a=, str(a))print(b=, str(b))
简化后内容:pythonimport numpythreshold=2a=np.array([[1, 2, 3], [3, 4, 5]])b=a > 2print(a)print(b)
我就废话不多说了,直接上代码吧!
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))
a=[[1 2 3] [3 4 5]] b=[[False False True] [ True True True]]
以上这篇在Python中通过threshold创建mask方式就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持易盾网络。
本文共计177个文字,预计阅读时间需要1分钟。
我将对原文进行简化改写,并确保不超过100个字:
pythonimport numpy as npthreshold=2a=np.array([[1, 2, 3], [3, 4, 5]])b=a > thresholdprint(a=, str(a))print(b=, str(b))
简化后内容:pythonimport numpythreshold=2a=np.array([[1, 2, 3], [3, 4, 5]])b=a > 2print(a)print(b)
我就废话不多说了,直接上代码吧!
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))
a=[[1 2 3] [3 4 5]] b=[[False False True] [ True True True]]
以上这篇在Python中通过threshold创建mask方式就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持易盾网络。

