我是新手,我正在尝试访问灰度图像的像素值
这是我的代码
im = cv.LoadImage("new.bmp")
# displaying the matrix form of image
for i in range(im.height):
for j in range(im.width):
print im[i,j],
print "\n",i
Run Code Online (Sandbox Code Playgroud)
我正在获取 RGB 每个像素值的输出,请参阅输出的快照
从 OpenCV 2 和 3 开始,LoadImage()
已经停产。请使用最新版本的 OpenCV imread()
。
用法-
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]
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
24703 次 |
最近记录: |