0
我已经使用Python 2.7,Numpy和OpenCV编写了一个程序,以从我的摄像头中抓取照片并给出每个像素的rgb值。在Python中索引NumPy图像数组时出错
for x in range(638):
for y in range(478):
red, green, blue = image[x, y]
print(red, green, blue)
我得到的错误信息:
red, green, blue = image[x, y]
IndexError: index 480 is out of bounds for axis 0 with size 480
有谁知道这是为什么在一个640×480像素的照片中运行代码后?
480是从0到479. – Maroun
是的我知道,试过 – skrhee
它是numpy和opencv中的[y,x]。另外,请不要**重复像这样的像素,这是可怕的慢,容易出错,并且完全击败了高级库的目的 – berak