mikhail_dvorkin

SciPy image example

May 12th, 2016
258
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.65 KB | None | 0 0
  1. import matplotlib.pyplot as plt
  2. import numpy as np
  3. from scipy import misc
  4.  
  5. h = misc.imread("a.jpg")
  6. print(h.shape)
  7.  
  8. f = misc.face(gray=True)
  9. print(f.shape)
  10. print(f.min(), f.max())
  11.  
  12. g = f
  13. mask = g > 150
  14. g[mask] = 255
  15. print(g.min(), g.max())
  16. plt.imshow(g, cmap=plt.cm.gray)
  17.  
  18. h = misc.imrotate(h, 75)
  19. h = misc.imresize(h, (90, 90))
  20. plt.contour(h, 4)
  21.  
  22. plt.figure()
  23. plt.imshow(g[80:90, 80:90], interpolation="nearest")
  24.  
  25. plt.show()
  26.  
  27. for i in range(10):
  28.     plt.figure()
  29.     x = np.arange(100)
  30.     y = np.random.rand(100)
  31.     plt.plot(x, y)
  32.     plt.savefig(str(i) + ".pdf")
  33. plt.imsave("a.png", g, cmap=plt.cm.gray)
  34. misc.imsave("a.jpg", g)
Add Comment
Please, Sign In to add comment