寻找绘制Ilnumerics中的体积切片的示例

时间:2016-03-31 02:18:49

标签: c# plot 3d large-data-volumes ilnumerics

是否有任何用于在Ilnumerics使用社区版本中绘制体积切片的示例。这是我从matlab网站获得的一个例子:

Volumetric slice image example of matlab

我有X,Y,Z作为位置,V(速度)作为颜色绘图的值。我所做的只是使用Ilpoints绘制位置X,Y,Z的V不是表面。这是我的代码和结果,

ILArray<float> plotXY = ILMath.zeros<float>(3, XcoordinateXY.Length);
        plotXY["0;:"] = ILMath.tosingle(SurfaceXY[":;:;1"]);
        plotXY["1;:"] = ILMath.tosingle(SurfaceXY[":;:;2"]);
        plotXY["2;:"] = ILMath.tosingle(SurfaceXY[":;:;3"]);

        ILArray<float> ColorMap = ILMath.tosingle(SurfaceXY[":;:;0"]);

var ilsurfaceplotXY = new ILPoints()
        {

            /*Wireframe = { Color = Color.FromArgb(50, Color.LightGray) },
            Colormap = new ILColormap(dataXY),
            Children = { new ILColorbar() }*/
            Positions = plotXY,
            Colors = cm.Map(ColorMap).T,
            Color = null
        };

以下是显示代码:

 var scene = new ILScene();
        scene.Add(
                new ILPlotCube
                {
                    TwoDMode = false,
                    Axes =
                    {

                        XAxis =
                        {
                            Label = { Text = "UTM X (Km)" },
                            GridMajor =
                            {
                                DashStyle = DashStyle.Dashed,
                                Color = Color.DarkGray,
                                Width = 1

                            }
                        },
                        YAxis =
                        {
                            Label = { Text = "UTM Y (Km)" },
                            GridMajor =
                            {
                                DashStyle = DashStyle.Dashed,
                                Color = Color.DarkGray,
                                Width = 1
                            }
                        },
                        ZAxis =
                        {
                            Label = { Text = "DEPTH (Km)" },
                            GridMajor =
                            {
                                DashStyle = DashStyle.Dashed,
                                Color = Color.DarkGray,
                                Width = 1
                            }
                        }
                    },

                    Children = { ilsurfaceplotXY, ilsurfaceplotXZ, ilsurfaceplotYZ },
                }
            );

        this.ilPanel1.Scene = scene;
        this.ilPanel1.Scene.Configure(); 
        this.ilPanel1.Refresh();

这是图像结果。

Result Image

对不起图片在链接中。

1 个答案:

答案 0 :(得分:1)

关于可视化,可以使用regular surfacesimagesc plotsDrawing2工具箱中的新快速表面来完成此操作。它们都允许为每个网格点或平铺块提供X,Y和Z值以及颜色。

关于点的计算:似乎你只是从可用集中选择点。在这些点之间进行插值会好得多。插值工具箱提供网格化和分散数据插值的功能。 (在您的情况下,数据似乎是网格化的?)。这允许以任意方向/角度具有切片。插值工具箱会插入切片网格点的位置以及颜色的值。

来自online example

Interpolation and visualization of sliced data from volumes

水平切片的设置如下:

ILArray<float> C; 
for (int i = 0; i < m_nrSlices; i += m_nrSlices / 4) {
    C = m_V[":",":", i];
    pc1.Add(new ILSurface(grid + i, C, colormap: Colormaps.Bone) 
    { 
        Wireframe = { Visible = false },
    });

}

此处,m_V是您的3D数据集,作为3D数组处理。 pc是情节立方体。表面只是添加到绘图立方体中。当用户移动红球时,动态计算红色插值区域的点:

// Points on the cutting area are considered scattered points, because the area is not (necessarily) plain. However, V 
// is a grid. interp3s interpolates the scattered points very efficiently. 
// Note how the shape of the coordinate arrays Xn, Yn and Zn is not important. interp3s takes their elements in sequential order. 
// The output is a vector of interpolated values. (We gonna reshape it below.)
ILArray < float> Z = Interpolation.interp3s(m_V, m_x, m_x, m_x, m_Xn, m_Yn, Zn, method: InterpolationMethod.cubic);

// let's plot! We get a reference to the fast surface
var fsurf = ilPanel1.Scene.First<ILFastSurface>("dynslice"); 
if (fsurf != null) {
    // first time setup only: provide the full coordinates of X and V. Here it is sufficient to provide grid vectors. 
    if (fsurf.Cols == 0) {
        fsurf.Update(X: m_xn * res, Y: m_xn * res, Z: Zn * res, C: ILMath.reshape(Z, Zn.S), colormap: Colormaps.Hot);
    } else {
        // the grid was configured already and did not change. we save some recomputing by ommiting the X and Y coordinates, prevent from reshaping buffers.
        fsurf.Update(Z: Zn * res, C: ILMath.reshape(Z, Zn.S), colormap: Colormaps.Hot);
    }
}
fsurf.Configure();
ilPanel1.Refresh(); 

进入细节超出了SO的范围。您可以下载该示例并在您的计算机上运行它。但是,您需要recent version的ILNumerics。

编辑:当然,您提供的图中的轴对齐切片只是一个子域。生成它们的方式完全相同: enter image description here