繁体   English   中英

Python-在不使用ImgOps'invert'或其他内置函数的情况下反转位图图像

[英]Python - inverting a bitmap image without using ImgOps 'invert' or other built-in functions

我想知道如何使用PIL在Python中反转图像,但我不能使用“反转”或“转换”或任何其他“简便”的方式进行转换。

任何帮助,将不胜感激。 谢谢 :)

看看im.load()

pix = im.load()
print pix[x, y]
pix[x, y] = value

像这样反转RGB元组:

red, green, blue = pixel
red = 256 - red
green = 256 - green
blue = 256 - blue
pixel = red, green, blue

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM