Python Pillow Image Invert
来源:互联网 发布:下载淘宝网天猫商城 编辑:程序博客网 时间:2024/05/17 07:16
本文主要是利用Python的第三方库Pillow,实现单通道灰度图像的颜色翻转功能。
# -*- encoding:utf-8 -*-import osimport sysfrom PIL import Imagefrom PIL import ImageOpsdef img_gray_invert(img_path): """ invert input image. """ if not os.path.isfile(img_path): print "Error for input file path." return image = Image.open(img_path) image = image.convert("L") inverted_image = ImageOps.invert(image) return inverted_imageif __name__ == '__main__': argv = sys.argv if len(argv) != 3: print """Example: python gray_invert.py test/htc.png test/htc_inv.png """ else: img_file_path = argv[1] invert_image = img_gray_invert(img_file_path) img_file_out = argv[2] invert_image.save(img_file_out)
参考
[1] How to invert colors of image with PIL (Python-Imaging)?
阅读全文
0 0
- Python Pillow Image Invert
- Python pillow Image图像处理
- invert Image
- Python-pillow
- python pillow
- Pillow学习之Image
- 【python 图像处理】Python图像处理模块pillow子模块Image用法精要
- invert color of image
- Python入门:PIL(pillow)之im对象(Image.open('file.jpeg'))
- python PIL PILLOW
- 使用python的pillow
- python pillow模块
- python安装Pillow
- python Pillow 模块安装
- python Pillow 处理图片
- fedora python pillow pil
- python 安装Pillow
- python安装Pillow库
- C++Vector
- ThinkPhP3.2中图片添加,并生成缩略图
- 18 Concurrency and Synchronization
- ListView点击checkbox其他checkbox也被同时选中的问题
- 19 Performance
- Python Pillow Image Invert
- 关于eclipse中@override报错原因及解决办法
- Anagrams问题(颠倒字母形成的新单词)
- hive中UDF和UDAF使用说明
- 解决caffe debug 1-Pycharm import caffe 报错 no module named caffe
- js 把一个数组分割成 n 个一组
- <java EE 项目:Attendance> 从一个简单项目看java web 开发的整体布局
- gulp--gulp-autoprefixer
- 总结“生成账单”功能的要点