daily pastebin goal
14%
SHARE
TWEET

High-dimensional image representation

qblius Jun 7th, 2012 41 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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()
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top