0
我想制作一个具有与图像中某些单元格对应的蒙版。这些单元格的RGB颜色值中的至少一个应该大于阈值。这里是我的代码无法正常工作:NumPy在哪里获取单元格的最大(R,G,B)>阈值的条件
B = image[0:h,0:w,0].astype(int)
G = image[0:h,0:w,1].astype(int)
R = image[0:h,0:w,2].astype(int)
mask = np.zeros((h,w))
mask[np.where(max(R,G,B) > threshold)] = 1
这给出了一个错误:
ValueError occurred Message=The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()
它工作!谢谢:D –
@AhmedMaher https://meta.stackexchange.com/help/someone-answers –