On 2010-07-09 07:25:16 +0200, Gael Varoquaux said:

> 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)

This 2nd way I have tried many times, as I am working completely in 
numpy arrays, but I always get flat object, like this:
http://dl.dropbox.com/u/139035/snapshot.png

What I would like it to do, is to take the luminance values and use 
them as elevation to draw a 3d elevated object, with the brightest 
pixels being the highest.

My system is the latest Enthought environment (6.2.2, 32-bit on the Mac).

Thank you!
Michael


> 
> 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




------------------------------------------------------------------------------
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

Reply via email to