On Fri, Jul 09, 2010 at 12:53:28AM +0200, K.-Michael Aye wrote:
> I am a new mayavi user and am trying to replicate the simple IDL
> behaviour of it's surf function.
> There, when I have a grey-scale image, for example, I can just give it
> to the 'surf-'function, and it plots a 3D graph, taking the luminance
> values of the image as elevation for the 3D display.
> Does this not exist in mayavi?
> I tried to use mlab.surf for 2 hours now, but I just can not understand
> all these grid creation stuff, as I never needed that in IDL, is that
> really necessary to just plot the image as a 3D object? Everything I
> tried with mlab.surf just gave me a flat object.
> I can run the example code for mlab.surf fine, but I am afraid I am
> doing something wrong, when i create the x and y grid, which would
> contain nothing but the index values of the image data anyway.
> Shouldn't this be simpler? Maybe I just missed something?
> I am grateful for any hint!
Very quickly and untested (I need to run):
First way, without any other dependencies:
from enthought.mayavi import mlab
img = mlab.pipeline.open('img.png')
w = mlab.pipeline.warp_scalar(img)
surf = mlab.pipeline.surface(mlab.pipeline.poly_data_normals(w))
Second way, using scipy to load the image as an array:
from scipy.ndimage import imread
img = imread('img.png')
mlab.surf(img)
HTH,
Gaƫl
------------------------------------------------------------------------------
This SF.net email is sponsored by Sprint
What will you do first with EVO, the first 4G phone?
Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first
_______________________________________________
MayaVi-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mayavi-users