簡體   English   中英

我無法使用 python 打印圖像的像素值

[英]i am not able to print the values of pixels of my image using 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
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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM