ppppp

漆器  •  2小时前


from PIL import Image def changel(x):

return x * 1.1

def changed(x):

return x * 0.3

def first(img, imgb):

img1 = img.load()
img2 = imgb.load()
x, y = img.size
for i in range(x):
    for j in range(y):
        a = img1[i,j]
        b = img2[i,j]
        color = 255 - a + b
        if color > 200:
            img1[i, j] = 160 - a + b
        else:
            img1[i, j] = color
return img

def main(img1, img2):

img = Image.open(img1).convert('L')
imgb = Image.open(img2).convert('L')
imgb = imgb.resize(img.size)
img = img.point(changel)
imgb = imgb.point(changed)
p = first(img, imgb)
p.save('first.png')

if name == 'main':

main('3.png', '4.png')

评论:

请先登录,才能进行评论