2016-03-31 21 views
-1

是否有任何用于在Ilnumerics中使用社区版本绘制容积切片的示例。这是一个例子,我从MATLAB网站得到:寻找在Ilnumerics中绘制容积切片的示例

Volumetric slice image example of matlab

我有阵列X,Y,Z如posistions和V(速度)成为用于彩色绘图值。我所做的全部工作就是使用Ilpoint在位置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

关于可视化,这可以使用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的范围。您可以下载该示例并在您的机器上运行它。尽管如此,你将需要一个ILNumerics的recent version

编辑:轴对齐的切片,因为你提供的情节只是一个子域,当然。生成它们的方式非常相似: enter image description here

+0

这就是我要找的东西......感谢这么多@Haymo Kutschbach – Cas

+0

对SO表示感谢的方式是将upvote和mark标记为答案;) –