[英]i am not able to print the values of pixels of my image using python
I am trying to calculate the pixels of a raster image using python, and i found this code in the website:我正在尝试使用 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
import numpy as np
from PIL import Image
i = Image.open('name of your jpg.jpg')
array = np.asarray(i)
print(array)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.