我无法使用python打印图像的像素值

2024-10-01 15:33:53 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在尝试使用python计算光栅图像的像素,我在网站上找到了以下代码:

path4 = "./bmp.bmp"
brownbox= cv2.imread(path4)
brownkbox=cv2.resize(brownbox, (0,0), fx=0.5, fy=0.5)
brownbox2_gray= cv2.cvtColor(brownbox, cv2.COLOR_BGR2GRAY)
cv2.imshow("gray",brownbox2_gray)
cv2.waitKey(0)

rows,cols = brownbox2_gray.shape
for i in range(rows):
    for j in range(cols):
        k = img[i,j]
        print (k)

k values are not being printed? only the images are shown

Tags: in图像for光栅range像素cv2are

热门问题