简体   繁体   English

在MATLAB中从一组内部3D散点图绘制曲面

[英]Plotting a surface from a set of interior 3D scatter points in MATLAB

I have a large (~60,000) set of triplet data points representing x,y, and z coordinates, which are scattered throughout a Cartesian volume. 我有一个大的(~60,000)三元组数据点,代表x,y和z坐标,它们分散在整个笛卡尔体积中。

I'm looking for a way to use Matlab to visualize the non-convex shape/volume described by the maximum extent of the points. 我正在寻找一种方法来使用Matlab来可视化由点的最大范围描述的非凸形状/体积。

I can of course visualize the individual points using scatter3 , but given the large number of points the details of the shape are obscured by the noise of the dots. 我当然可以使用scatter3显示各个点,但是在给定大量点的情况下,形状的细节会被点的噪声遮挡。

As an analogy, imagine that you filled a hour glass with spheres of random sizes such as BBs, ping pong balls, and kix and then were given the coordinates of the center of each of each object. 作为一个类比,想象你用一个随机大小的球体填充一小时玻璃,如BBs,乒乓球和kix,然后给出每个物体的每个物体的中心坐标。 How would you take those coordinates and visualize the shape of the hour glass containing them? 您如何获取这些坐标并可视化包含它们的沙漏的形状?

My example uses different sized objects because the spacing between data points is non-uniform and effectively random; 我的例子使用不同大小的对象,因为数据点之间的间距是不均匀的并且是有效随机的; it uses an hourglass because the shape is non-convex. 它使用沙漏,因为形状是非凸的。

If your surface enclosing the points can be described as a convex polyhedron (ie like the surface of a cube or a dodecahedron , without concave pits or jagged pointy parts ), then I would start by creating a 3-D Delaunay triangulation of the points. 如果包围点的表面可以描述为凸多面体 (即像立方体或十二面体的表面,没有凹坑或锯齿状尖部 ),那么我将首先创建点的三维Delaunay三角剖分 This will fill the volume around the points with a series of tetrahedral elements with the points as their vertices, and you can then find the set of triangular faces that form the outer shell of the volume using the convexHull method of the DelaunayTri class. 这将用点作为顶点的一系列四面体单元填充点周围的体积,然后您可以使用DelaunayTri类的convexHull方法找到构成体积外壳的三角形面的集合。

Here's an example that generates 200 random points uniformly distributed within the unit cube, creates a tetrahedral mesh for these points, then finds the 3-D convex hull for the volume: 这是一个生成在单位立方体内均匀分布的200个随机点的示例,为这些点创建四面体网格,然后找到该体积的三维凸包:

interiorPoints = rand(200,3);      %# Generate 200 3-D points
DT = DelaunayTri(interiorPoints);  %# Create the tetrahedral mesh
hullFacets = convexHull(DT);       %# Find the facets of the convex hull

%# Plot the scattered points:
subplot(2,2,1);
scatter3(interiorPoints(:,1),interiorPoints(:,2),interiorPoints(:,3),'.');
axis equal;
title('Interior points');

%# Plot the tetrahedral mesh:
subplot(2,2,2);
tetramesh(DT);
axis equal;
title('Tetrahedral mesh');

%# Plot the 3-D convex hull:
subplot(2,2,3);
trisurf(hullFacets,DT.X(:,1),DT.X(:,2),DT.X(:,3),'FaceColor','c')
axis equal;
title('Convex hull');

在此输入图像描述

You could treat your data as a sample from a three-dimensional probability density, and estimate that density on a grid, eg via a 3d histogram, or better a 3d kernel density estimator . 您可以将数据视为三维概率密度的样本,并估算网格上的密度,例如通过三维直方图,或更好的三维核密度估计 Then apply a threshold and extract the surface using isosurface . 然后应用阈值并使用isosurface提取曲面。

Unfortunately, hist3 included in the Statistics Toolbox is (despite its name) just a 2d histogram, and ksdensity works only with 1d data, so you would have to implement 3d versions yourself. 不幸的是,统计工具箱中包含的hist3 (尽管它的名字)只是一个2d直方图,而ksdensity只能用于1d数据,所以你必须自己实现3d版本。

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

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