SourceForge logo
SourceForge logo
Menu

matplotlib-users

From: Brickle M. <bri...@gm...> - 2012年10月30日 14:40:41
For some fun I am trying to plot a surface representation of 2D image 
where the height level corresponds to the intensity at each pixel. I 
have been able to change the cmap but would like to assign the original 
pixel colour values (Grayscale or RGB) to corresponding in the surface 
plot. Is this possible? To be honest, I not even sure if I have 
constructed the plot correctly.
Any help appreciated.
Regards,
Brickle.
----
----- Surface Representation of 2D Image --------
from mpl_toolkits.mplot3d import axes3d
import matplotlib.pyplot as plt
from skimage import data, color
import numpy as np
from scipy import ndimage
from matplotlib import cm
image = color.rgb2gray(data.lena())
image = ndimage.gaussian_filter(image, 8)
x = range(image.shape[0])
y = range(image.shape[1])
X,Y = np.meshgrid(x,y) # Is this the correct way?
Z = image # Not sure if this is correct?
fig = plt.figure()
ax = fig.add_subplot(1,1,1, projection='3d')
ax.plot_surface(X,Y,Z, cmap=cm.gray)
plt.show()
----------------------------------------------
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.
Thanks for helping keep SourceForge clean.
X





Briefly describe the problem (required):
Upload screenshot of ad (required):
Select a file, or drag & drop file here.
Screenshot instructions:

Click URL instructions:
Right-click on the ad, choose "Copy Link", then paste here →
(This may not be possible with some types of ads)

More information about our ad policies

Ad destination/click URL:

AltStyle によって変換されたページ (->オリジナル) /