import cv2
img = cv2.imread("new.bmp", 0) #since the image is grayscale, we need only one channel and the value '0' indicates just that
for i in range (img.shape[0]): #traverses through height of the image
for j in range (img.shape[1]): #traverses through width of the image
print img[i][j]
首先使用最新的Opencv 3。要将图像转换为灰度并打印像素值,请执行以下代码
从OpenCV 2和OpenCV 3开始,
LoadImage()
已经停止。请改用最新版本的OpenCV和imread()
。用法-
文档:http://docs.opencv.org/modules/highgui/doc/reading_and_writing_images_and_video.html?highlight=imread#imread
相关问题 更多 >
编程相关推荐