【发布时间】:2021-12-10 04:44:08
【问题描述】:
enter image description here我想检测图像中形状的颜色,所以当我运行代码时 “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
【问题讨论】:
-
只是猜测:尝试将索引行更改为
bgr_list = img[cY,cX] -
感谢@DominikFicek,它成功了,你能告诉我反转坐标背后的逻辑吗?
标签: python-3.x opencv image-processing numpy-ndarray color-detection