我想要访问然后在Python中重新着色图像的像素。几个不同的教程,包括this one使用此方法来访问像素:使用cv2访问图像的像素
import cv2
import numpy as np
image = cv2.imread('ironman.bmp')
pixel = image[200, 500]
print pixel
我试了一下,但pixel = image[200, 500]
命令后,我收到以下错误信息:
Traceback (most recent call last):
File "<pyshell#3>", line 1, in <module>
pixel = image[200, 500]
TypeError: 'NoneType' object is not subscriptable
一些研究,我想通了之后错误消息意味着image[200, 500]
的值是None
。但是教程使用这个代码没有这个问题。有人能告诉我我可能会做错什么吗?我正在使用Python 3.6.0。
请检查值in'image' ,我认为这是'没有'。 –
什么是图像层? 'pixel = image [200,500,0]'怎么样? – jean