Created
October 25, 2019 14:53
-
-
Save BenedictWilkins/d71ff0c462d39d8dc59a0dbe7411224f to your computer and use it in GitHub Desktop.
Plot an Image in 3D with pyplot
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
# -*- coding: utf-8 -*- | |
""" | |
Created on Thu Oct 24 19:33:19 2019 | |
Plot an image in 3D using pyplot. | |
Assumes image is grayscale and in HWC format. | |
@author: Benedict Wilkins | |
""" | |
import matplotlib.pyplot as plt | |
import numpy as np | |
img = np.random.uniform(size=(10,10,1)) | |
X = np.arange(0, img.shape[1]) | |
Y = np.arange(0, img.shape[0]) | |
X, Y = np.meshgrid(X, Y) | |
Z = img.squeeze() | |
fig = plt.figure() | |
ax = fig.gca(projection='3d') | |
surf = ax.plot_surface(X, Y, Z) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment