AttributeError:' list'对象没有属性' putpixel'

时间:2018-06-06 11:17:13

标签: python-3.x

    from PIL import Image
    import cv2
    import numpy as np
    img2 = cv2.imread("D:/0606/2.jpg")
    grayimg2 = cv2.cvtColor(img2,cv2.COLOR_BGR2GRAY)
    cv2.imshow("grayimg2",grayimg2)
    width_2,heigh_2 = grayimg2.shape
    img1 = cv2.imread("D:/0606/1.jpg")
    grayimg1 = cv2.cvtColor(img1,cv2.COLOR_BGR2GRAY)
    cv2.imshow("grayimg1",grayimg1)
    width_1,heigh_1 = grayimg1.shape
    for y in range(heigh_2):
        for x in range(width_2):
            i=int(grayimg2[x,y])
            j=int(grayimg1[x,y])
            a=abs(i-j)
            if abs(i-j)>114:
               a=255
            else:
               a=0
            img=[]
            img.putpixel((x,y),a)

img.putpixel((X,Y),一个)
AttributeError:' list'对象没有属性' putpixel'
在我的代码输入两个图像并转换为graylevel
读取img1和img2中的每个像素灰度级 如果img2> img1把a = 255 否则a = 0
怎么能把" a"在一张新照片中获得一张新的灰度图片

0 个答案:

没有答案