def desaturate_image(self, image):
desatimage = Image.new(image.mode, image.size)
pixellist = []
print(len(pixellist))
for x in range(image.size[0]):
for y in range(image.size[1]):
r, g, b = image.getpixel((x, y))
greyvalue = (r+g+b)/3
greypixel = (int(round(greyvalue)), int(round(greyvalue)), int(round(greyvalue)))
pixellist.append(greypixel)
print(pixellist)
desatimage.putdata(pixellist)
return desatimage
我正在编写一个python方法,将作为参数传递的图像转换为灰度。我得到的结果虽然不正确。这是输入和输出。哪里错了?
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句