%matplotlib inline
from scipy.misc import lena
import numpy as np
import matplotlib.pyplot as plt
ima = lena()
plt.imshow(ima, cmap=plt.cm.gray)
--------------------------------------------------------------------------- RuntimeError Traceback (most recent call last) <ipython-input-1-bedea41f6ea1> in <module>() 3 import numpy as np 4 import matplotlib.pyplot as plt ----> 5 ima = lena() 6 plt.imshow(ima, cmap=plt.cm.gray) C:\Anaconda3\lib\site-packages\scipy\misc\common.py in lena() 332 face, ascent 333 """ --> 334 raise RuntimeError('lena() is no longer included in SciPy, please use ' 335 'ascent() or face() instead') 336 RuntimeError: lena() is no longer included in SciPy, please use ascent() or face() instead
print ima.shape
(512, 512)
ima2=ima.copy()
for xx in range(512):
for yy in range(1,511):
ima2[xx,yy]=(ima[xx,yy-1]+ima[xx,yy]+ima[xx,yy+1])/3.0
plt.imshow(ima2,cmap=plt.cm.gray)
<matplotlib.image.AxesImage at 0xbe25030>
ima2=ima.copy()
for xx in range(512):
for yy in range(511):
ima2[xx,yy]=abs(ima[xx,yy]-ima[xx,yy+1])
plt.imshow(ima2,cmap=plt.cm.gray)
plt.clim(0,10)
plt.colorbar()
<matplotlib.colorbar.Colorbar instance at 0x0BF70E68>
plt.figure(figsize=(15,5), dpi=300)
plt.subplot(121)
plt.imshow(ima, cmap=plt.cm.gray)
for kk in range(10):
for xx in range(510):
for yy in range(1,511):
ima2[xx,yy]=(ima[xx,yy-1]+ima[xx,yy]+ima[xx,yy+1])/3.0
ima=ima2.copy()
plt.subplot(122)
plt.imshow(ima2,cmap=plt.cm.gray)
<matplotlib.image.AxesImage at 0xbff0910>