from scipy import misc import matplotlib.pyplot as plt lena=misc.lena();print lena.shape lena2=lena.repeat(3,axis=0).repeat(2,axis=1);print lena2.shape #resize plt.figure(0) plt.subplot(211) plt.imshow(lena) plt.subplot(212) plt.imshow(lena2) plt.figure(1) acopy=lena.copy();print acopy.shape #copy aview=acopy.view() aview.flat=0 plt.imshow(aview) plt.figure(2) plt.imshow(lena[:,::-1]) #overturn plt.figure(3) plt.imshow(lena[:,:256]) #cut plt.figure(4) plt.imshow(lena[:lena.shape[0]/2,:lena.shape[1]/2]) #cut 2 plt.figure(5) mask=lena%2==0 #bool mask masked=lena.copy() masked[mask]=0 plt.imshow(masked) #mask plt.show()
搜索
复制
时间: 2024-10-19 18:17:02