Advertisement
qblius

High-dimensional image representation

Jun 7th, 2012
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.56 KB | None | 0 0
  1. from PIL import Image
  2. import matplotlib.pyplot as plt
  3. from mpl_toolkits.mplot3d import Axes3D
  4. import numpy as np
  5.  
  6. im = Image.open('banana.jpg').resize((64,64)).transpose(Image.FLIP_TOP_BOTTOM)
  7. nim = np.asarray(im)
  8. z = np.asarray(im.convert('L'))*1.
  9.  
  10. fig = plt.figure()
  11. ax = fig.add_subplot(111, projection='3d')
  12. x, y = np.meshgrid(range(nim.shape[0]), range(nim.shape[1]))
  13. colors = nim/255.
  14. colors = colors.reshape((colors.shape[0]*colors.shape[1],3))
  15. ax.scatter(x.ravel(), y.ravel(), z.ravel(),
  16.     marker='.',facecolors=colors,edgecolors=colors)
  17. plt.show()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement