scipy学习之(二)——io操作及其misc操作对图片的处理

SciPy有许多模块、类和函数,io子模块可用于从各种文件格式中读取数据和将数据写入各种文件格式。

from scipy import io

import numpy as np

生成数据

data = np.random.randint(0,100,size = (10,3))

保存数据:保存成mat格式的二进制文件

io.savemat("./data.mat",mdict = {"data":data})

加载数据

ret = io.loadmat("./data.mat")

读取生成的数据

ret["data"]

显示结果:

array([[90, 39, 31],
       [45,  8, 75],
       [75, 17,  5],
       [84, 62, 87],
       [30, 22, 32],
       [37, 15, 97],
       [67, 61, 95],
       [43, 13,  7],
       [27, 31, 40],
       [77, 25, 56]])

misc

是scipy中一个很杂的模块

介绍对图片进行过滤的方式

from scipy import misc
import matplotlib.pyplot as plt
%matplotlib inline

he = misc.imread("./timg1.jpg")

原图:

import warnings
warnings.filterwarnings("ignore")        #忽略警告问题

#imfilter中的一些属性如下列表,

类似高斯滤波的卷积操作

array = [ 'blur', 'contour', 'detail', 'edge_enhance', 'edge_enhance_more','emboss', 'find_edges', 'smooth', 'smooth_more', 'sharpen']
he1 = misc.imfilter(he,array[0])

显示第二个属性样式
plt.imshow(he1)

 

转载于:https://www.cnblogs.com/kuangkuangduangduang/p/10292183.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值