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 –