简体   繁体   English

使用Mayavi和Mlab绘制“气泡”

[英]Using Mayavi and Mlab to plot “bubbles”

Currently, I am attempting to plot some "bubble" like shapes in a 3D space using Mayavi/Mlab. 目前,我正在尝试使用Mayavi / Mlab在3D空间中绘制一些类似形状的“气泡”。 These bubbles are represented by a numpy array of shape (840,1100,30) where the parameters represent (x,y,z) and the value at any x,y,z is either 1 or 0. The array can be thought of as a collection of Voxels that are either on or off. 这些气泡由形状为(840,1100,30)的numpy数组表示,其中参数表示(x,y,z)并且任何x,y,z都为1或0。作为已打开或关闭的体素的集合。 I try to plot this data with the following commands: 我尝试使用以下命令绘制此数据:

mlab.contour3d(finalVolume)
mlab.show()

But the plot is coming out in 2 dimensions instead of in 3 dimensions. 但是该图以2维而不是3维的形式出现。 I have looked at the documentation but am having trouble understanding. 我查看了文档,但难以理解。 If anyone could provide some help or a push in the right direction, then I would be very appreciative! 如果有人可以提供一些帮助或朝着正确的方向推进,那么我将不胜感激! Thanks! 谢谢!

Sounds like you need to use volume rendering to accomplish this. 听起来您需要使用体积渲染来完成此任务。 This can be accomplished using: 可以使用以下方法完成此操作:

mlab.pipeline.volume(mlab.pipeline.scalar_field(s), vmin=0, vmax=0.8)

You will need to adjust the opacity transfer function using vmin and vmax to make an appropriate image. 您将需要使用vmin和vmax调整不透明度传递函数,以制作合适的图像。 Examples on volume rendering can be found at: http://docs.enthought.com/mayavi/mayavi/mlab.html 可以在以下位置找到有关体积渲染的示例: http : //docs.enthought.com/mayavi/mayavi/mlab.html

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM