首页 > 编程语言 > 详细

python图像处理

时间:2019-07-25 21:30:44      阅读:103      评论:0      收藏:0      [点我收藏+]

Python常用处理图像的库是PIL,另外还有opencv、Matplotlib、NumPy、SciPy、skimage 详情请参考:https://www.cnblogs.com/qiaozhoulin/p/4509954.html、  https://www.cnblogs.com/skyfsm/p/8276501.html

PIL:Python Imaging Library,已经是Python平台事实上的图像处理标准库了。PIL功能非常强大,但API却非常简单易用,但其只支持Python 2.7,在PIL的基础上创建了兼容的版本,名字叫Pillow,支持最新Python 3.x

1.缩放篇

Image.resize()函数用于修改图片的尺寸;Image.thumbnail()函数用于制作当前图片的缩略图。from PIL import Image

img01= Image.open(‘F:/pytest/101.jpeg‘)
img01.show()
w01,h01=img01.size # 获得图像尺寸:
print(‘current image01 size:%sX%s‘%(w01,h01))

img01.thumbnail((w01//2,h01//2)) # 缩放到50%:
img01.save(‘F:/pytest/102.jpeg‘,‘jpeg‘) # 缩放后保存为102.jpeg
img02=Image.open(‘F:/pytest/102.jpeg‘)
img02.show()
w02,h02=img02.size # 获得图像尺寸:
print(‘current image02 size:%sX%s‘%(w02,h02))

#print(‘resized size‘,img01.resize((128,128)).size)
img03 = img01.resize((128,128)) #t图像修改尺寸为128*128
img03.save(‘F:/pytest/103.jpeg‘,‘jpeg‘)
img03.show()
w03,h03=img03.size # 获得图像尺寸:
print(‘current image03 size:%sX%s‘%(w03,h03))

2.旋转篇

待续

python图像处理

原文:https://www.cnblogs.com/jintianniu/p/11246791.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!