【问题标题】:Calculating 3d Point Normals in MATLab在 MATLab 中计算 3d 点法线
【发布时间】:2013-12-25 01:58:18
【问题描述】:

我在 MATLab 中有一个 3d 点的点云。点云采用 3xN 矩阵的形式。

我想以 3xN 矩阵的形式计算每个点的法线。我该怎么做呢?

到目前为止,我已经尝试过使用

nX = (surfnorm(X'))';

X 是我的点云,nX 应该是我返回的法线。但是,每当我尝试以这种方式进行渲染时,它似乎都不起作用......这是正确的方法吗?

提前致谢!

【问题讨论】:

    标签: matlab 3d normals point-clouds


    【解决方案1】:

    surfnorm 需要一个曲面,因此它将您的 3 x N 点位置矩阵作为 3 x N 大小的曲面(调用 surfnorm 时,输入将 Z、X 和 Y 设置为默认值)。我没有看到直接在点云上使用此功能的任何方式。

    为了从点云中找到法线,您需要:

    1) 拟合点云中的某种表面,然后在其上使用surfnorm。 2) 使用周围点估计每个点的法线。 This site 提供了很好的概述。

    file exchange 上实际上有一个文件,它演示了从给定的一组点(一组给定的点的单个法线)计算法线。您需要做的是为每个点计算一组最近邻,然后返回法线向量。您可能还需要更正矢量的方向。

    【讨论】:

      【解决方案2】:

      由于您拥有 3 x N 点云,假设它的名称为 mat。那么我建议采取以下方法:

      % Constructing the Point Cloud and Data Structure
      ptCloud = pointCloud(mat);
      
      % Normal Esitmation (3 is simply tthe number of points used for local plane fitting)
      normals = pcnormals(ptCloud,3);
      

      此时,您的法线以 (3N) x 3 矩阵的形式计算。您可以通过

      将其添加为点云的属性
      ptCloud.Normal = normals;
      

      为了将其可视化,可以执行以下操作:

      step_size = 10; 
      
      x = ptCloud.Location(1:step_size:end,1);
      y = ptCloud.Location(1:step_size:end,2);
      z = ptCloud.Location(1:step_size:end,3);
      u = ptCloud.Normal(1:step_size:end,1);
      v = ptCloud.Normal(1:step_size:end,2);
      w = ptCloud.Normal(1:step_size:end,3);
      
      % plot
      
      figure;
      hold on
      
      % plot the point cloud
      pcshow(ptCloud);
      
      % plot the normal arrows
      quiver3(x,y,z,u,v,w);
      
      hold off
      

      最后一条评论:与简单地绘制点矩阵相比,通过pointCloud 函数创建点云提供了更优化的可视化效果。

      【讨论】:

        猜你喜欢
        • 2013-05-20
        • 2014-11-05
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2010-11-12
        • 1970-01-01
        • 2013-02-15
        • 1970-01-01
        相关资源
        最近更新 更多