Advertisement
Guest User

Untitled

a guest
Jun 25th, 2019
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.71 KB | None | 0 0
  1. diamond = np.array([[ 0, 0, 0, 0, 255, 0, 0, 0, 0],
  2. [ 0, 0, 0, 255, 0, 255, 0, 0, 0],
  3. [ 0, 0, 255, 0, 0, 0, 255, 0, 0],
  4. [ 0, 255, 0, 0, 0, 0, 0, 255, 0],
  5. [255, 0, 0, 0, 0, 0, 0, 0, 255],
  6. [ 0, 255, 0, 0, 0, 0, 0, 255, 0],
  7. [ 0, 0, 255, 0, 0, 0, 255, 0, 0],
  8. [ 0, 0, 0, 255, 0, 255, 0, 0, 0],
  9. [ 0, 0, 0, 0, 255, 0, 0, 0, 0]], dtype=uint8)
  10.  
  11. size = 36
  12. my_dpi = mpl.rcParams['figure.dpi']
  13. plt.subplots(figsize=(size/my_dpi, size/my_dpi))
  14. plt.axis('off')
  15. img = Image.fromarray(diamond, 'L')
  16. img.resize((size,size)).save('diamond.ppm')
  17. plt.imshow(img)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement