Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from PIL import Image
- import matplotlib.pyplot as plt
- from mpl_toolkits.mplot3d import Axes3D
- import numpy as np
- im = Image.open('banana.jpg').resize((64,64)).transpose(Image.FLIP_TOP_BOTTOM)
- nim = np.asarray(im)
- z = np.asarray(im.convert('L'))*1.
- fig = plt.figure()
- ax = fig.add_subplot(111, projection='3d')
- x, y = np.meshgrid(range(nim.shape[0]), range(nim.shape[1]))
- colors = nim/255.
- colors = colors.reshape((colors.shape[0]*colors.shape[1],3))
- ax.scatter(x.ravel(), y.ravel(), z.ravel(),
- marker='.',facecolors=colors,edgecolors=colors)
- plt.show()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement