<PY><NumPy><SciPy>图像翻转切割遮罩

来源:互联网 发布:如何看待网络暴力演讲 编辑:程序博客网 时间:2024/06/06 18:57
from scipy import miscimport matplotlib.pyplot as pltlena=misc.lena();print lena.shapelena2=lena.repeat(3,axis=0).repeat(2,axis=1);print lena2.shape #resizeplt.figure(0)plt.subplot(211)plt.imshow(lena)plt.subplot(212)plt.imshow(lena2)plt.figure(1)acopy=lena.copy();print acopy.shape  #copyaview=acopy.view()aview.flat=0plt.imshow(aview)plt.figure(2)plt.imshow(lena[:,::-1])  #overturnplt.figure(3)plt.imshow(lena[:,:256])  #cutplt.figure(4)plt.imshow(lena[:lena.shape[0]/2,:lena.shape[1]/2])  #cut 2plt.figure(5)mask=lena%2==0  #bool maskmasked=lena.copy()masked[mask]=0plt.imshow(masked) #maskplt.show()

1 0
原创粉丝点击