python 之图像处理

1.对图像的处理

首先,对图像的处理需要提前安装第三方的PIL,可利用其对图像进行缩放、裁剪、旋转、色彩转换等一些处理工作。

举例一:设置一些图像的不同模式,open().convert(). convert中,可设置出“1”、“L”、“P”等不同模式。【“L”:8 bit像素,黑白】

from PIL import Image
import os
import matplotlib.pyplot as plt

print(os.getcwd())
os.chdir('C:\\Users\\读书人mn\\Desktop\\123123')
print(os.getcwd())

im=Image.open('four.jpg').convert('L')
print(im.format,im.size,im.mode)
#im.show()
plt.imshow(im)
plt.title('wenxuan')
plt.axis('off')
plt.show()

输出结果如下:

注:标题不要用“中文”

举例二:对图像进行模糊处理

从scipy导入过滤器,im2=filters.gaussian_filter(im,20)中数字20为模糊的程度。

from scipy.ndimage import filters
import matplotlib.pyplot as plt
from pylab import *

im=array(Image.open(
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值