在此處輸入影像描述我想檢測影像中形狀的顏色,因此當我運行代碼“bgr_list = img[cX,cY]”時,出現此錯誤:
bgr_list = img[cX,cY]
IndexError: index 648 is out of bounds for axis 0 with size 598
but when I run "bgr_list = img[300,300]" I do not get any error
->where [300,300] is white portion in image
-> where, cX = x-coordinate of centroid and cY = y-coordinate of centroid
-> BGR_list is bgr value of pixel at centroid
-> the size of image is 898x598 pixel
uj5u.com熱心網友回復:
看起來您從某種預處理中獲得 X 和 Y 笛卡爾坐標,但是numpyopencv 使用的矩陣使用矩陣索引(row, column, channel)。您的 X 坐標對應于列索引,Y 坐標是您的行索引。
翻轉索引應該可以完成作業
bgr_list = img[cY,cX]
轉載請註明出處,本文鏈接:https://www.uj5u.com/qiye/337941.html
標籤:蟒蛇-3.x opencv 图像处理 numpy-ndarray 颜色检测
下一篇:如何使用GIMP縮放影像?
