【问题标题】:Looking for example for plotting Volumetric Slice in Ilnumerics寻找在 Ilnumerics 中绘制体积切片的示例
【发布时间】:2016-07-19 07:03:15
【问题描述】:

有没有在 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

很抱歉图片在链接中。

【问题讨论】:

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


    【解决方案1】:

    关于可视化,这可以通过regular surfacesimagesc plotsDrawing2 工具箱中的新快速表面来完成。它们都允许为每个网格点或图块提供 X、Y 和 Z 值以及颜色。

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

    来自online example

    水平切片的设置如下:

    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 的范围。您可以下载示例并在您的机器上运行它。不过,您将需要 ILNumerics 的recent version

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

    【讨论】:

    • 这就是我要找的......非常感谢@Haymo Kutschbach
    • 对 SO 表示感谢的方式是投票并标记为答案 ;)
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2014-09-19
    • 2018-07-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多