4

I'm using mayavi in python to visualize some data. I have a surface in 3D space and I want to map an image to it. I have looked at mayavi documentation and all I could find was this, which really doesn't help me much. Has anybody done something like this before?

1
  • I have actually been able to acheive this in matplotlib, though with a very bad frame rate... Following the official examples for Axes3D.plot_surface(), simply set the keyword facecolors equal to your desired texture. I don't remember whether I tested it in RGB but it works in grayscale.
    – PhilMacKay
    Oct 22, 2013 at 17:38

2 Answers 2

2

I found that the mesh function actually does take a scalars argument, which then colors the corresponding point on the surface in accordance to the chosen colormap. I still however don't know how to map an arbitrary RGB image to the surface.

1
  • Okay. Now I know what you want to do, but I'm not sure how to solve it. Can the color option of surf help you?
    – ahelm
    Jan 3, 2012 at 16:31
1

I guess you didn't saw the chapter "Python scripting for 3D plotting". There is a collection of the mayavi commands which can be used inside python. For example the section "3D Plotting functions for numpy arrays". If you follow the links you find some description about the functions and a small example for each of them.

For your case you should take mesh or surf. Both functions are kind of equal, but are different. For example the surf function is more a subfunction of mesh, which is my opinion. You don't really have to define x and y-coordinates, you just need the z-coordinates in a 2D array. If you want to use mesh you have to pass all three coordinates (x,y,z) as 2D arrays.

I would suggest to check the examples.

Is this an answer to your question? Maybe you should be more specific about what you want to do.

Have a nice day and Happy Holidays.

1
  • 1
    Yes, I did see that. It turns out that it is poorly written. I guess you saw that too, as you are also unable to answer my question.
    – katrasnikj
    Jan 3, 2012 at 3:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.