【问题标题】:Converting convex hull to binary mask将凸包转换为二进制掩码
【发布时间】:2011-02-15 16:23:32
【问题描述】:

我想生成一个二进制掩码,其中所有体素都为 1,而体积外的所有体素都为 0。体积由一组 3D 坐标(

我可以使用CONVHULLN 获得凸包,但如何将其转换为二进制掩码?

如果没有通过凸包的好方法,您还有其他想法我可以如何创建二进制掩码吗?

【问题讨论】:

  • 你的意思是体素,不是像素,对吧?

标签: matlab geometry convex-hull


【解决方案1】:

您可以使用DelaunayTri classpointLocation method 解决此问题。这是一个例子:

pointMatrix = rand(20,3);       %# A set of 20 random 3-D points
dt = DelaunayTri(pointMatrix);  %# Create a Delaunay triangulation
[X,Y,Z] = meshgrid(0:0.01:1);   %# Create a mesh of coordinates for your volume
simplexIndex = pointLocation(dt,X(:),Y(:),Z(:));  %# Find index of simplex that
                                                  %#   each point is inside
mask = ~isnan(simplexIndex);    %# Points outside the convex hull have a
                                %#   simplex index of NaN
mask = reshape(mask,size(X));   %# Reshape the mask to 101-by-101-by-101

上面的示例为跨越单位体积的 101×101×101 网格创建了一个逻辑掩码(每个维度中为 0 到 1),其中 1(真)表示凸包内的网格点3-D 点集。

【讨论】:

    【解决方案2】:

    这里已经很晚了,所以只是一个非常粗略的建议:

    1. 使用凸包中的点构建 Delaunay 细分。
    2. 使用 DelaunayTri 类的 pointLocation 方法测试像素数组中的每个点。

    我希望这会很慢,并且有更好的解决方案,如果我梦到了,我明天再发一次。

    【讨论】:

      【解决方案3】:

      这是一个扫描转换问题。查看3D Scan-Conversion Algorithms for Voxel-Based Graphics 的第 8 部分。

      您想要的算法是实心算法,并且稍微简单一些,因为您正在对一个面为三角形的凸多面体进行体素化 - 每个“体素”运行都由两个三角形界定。

      【讨论】:

        猜你喜欢
        • 2020-03-12
        • 2019-02-13
        • 1970-01-01
        • 2016-07-17
        • 2013-09-28
        • 2016-07-16
        • 2020-12-22
        • 2017-02-04
        • 2014-03-01
        相关资源
        最近更新 更多