【发布时间】:2020-05-25 13:47:04
【问题描述】:
我正在尝试对灰度图像中的某些值进行阈值处理。到目前为止,我通过输入特定范围的数字已经成功,但我想取 50 到 150 之间的值并将它们乘以 1.2。我不确定如何访问向量中的数字,然后将其乘以 1.2。
myimg[myimg <= 50] = 0
myimg[myimg > 150 ] = 255
myimg[50<myimg<=150] = myimg * 1.2 #this line produces this error: ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()
【问题讨论】:
-
(myimg>50) & (myimg<=150)怎么样?可能你必须在两边都使用它myimg[(myimg>50) & (myimg<=150)] = myimg[(myimg>50) & (myimg<=150)] * 1.2或者写成更短的版本myimg[(myimg>50) & (myimg<=150)] *= 1.2
标签: python opencv image-thresholding