from scipy import io#保存与读写文件
import matplotlib.pyplot as plt
使用io.loadmat()读取数据
In [2]:
# io.loadmat('moon.mat',mdict={'moon':./moonlanding.png'})
# io.loadmat('./moonlanding.png')
读写图片使用scipy中的misc。imread()/imsave()
In [3]:
from scipy import misc
In [4]:
gilr=misc.imread('./cj0 (1).jpeg')
gilr
Out[4]:
In [5]:
# misc.imshow('./cj0 (1).jpeg')#这个方法只有在linux可以使用
In [6]:
import matplotlib.pyplot as plt
In [7]:
plt.imshow(gilr)
plt.show()
misc旋转,resize,imfilter(过滤切割图片)
In [8]:
g1=misc.imrotate(gilr,30)
In [9]:
plt.imshow(g1)
plt.show()
In [10]:
"""
size : int, float or tuple
* int - Percentage of current size.
* float - Fraction of current size.
* tuple - Size of the output image."""
g2=misc.imresize(g1,0.1)
plt.imshow(g2)
plt.show()
In [11]:
#滤波操作
'''
arr : ndarray
The array of Image in which the filter is to be applied.
ftype : str
The filter that has to be applied. Legal values are:
'blur', 'contour', 'detail', 'edge_enhance', 'edge_enhance_more',
'emboss', 'find_edges', 'smooth', 'smooth_more', 'sharpen'.'''
g3=misc.imfilter(gilr,'emboss')
plt.imshow(g3)
plt.show()
In [12]:
g3=misc.imfilter(gilr,'contour')
plt.imshow(g3)
plt.show()