【问题标题】:How can I calculate mean curvature and/or other type curvature in each point in point cloud?如何计算点云中每个点的平均曲率和/或其他类型的曲率?
【发布时间】:2014-04-01 23:42:12
【问题描述】:

我有一个 3D 点云,我想使用 matlab 代码计算点云中每个点的平均曲率。 我发现下面的代码是一个函数:

function [gm samc] = mcurvature_vec(x,y,z)
% Description: The function calculates mean curvature and 
% Surface Avg Mean Curvature (SAMC) of a surface formed by x, y & z. 
% The input are the coordinate matrices x, y & z. The 
% matrices can be formed using meshgrid or similar functions.
% This code is a vectorized form of original code (mcurvature) posted 
% on Matlab File Exchange.

% The mean curvature is calculated according to the formula:

% If x:U->R^3 is a regular patch, then the mean curvature is given by
%       
%         H = (eG-2fF+gE)/(2(EG-F^2)),  
% 
% where E, F, and G are coefficients of the first fundamental form and
% e, f, and g are coefficients of the second fundamental form 

% Reference: Gray, A. "The Gaussian and Mean Curvatures." §16.5 in 
% Modern Differential Geometry of Curves and Surfaces with Mathematica, 
% 2nd ed. Boca Raton, FL: CRC Press, pp. 373-380, 1997 (p. 377).

% Inspired by:
% Title:    Mean Curvature
% Author:   Ahmed Elnaggar
% Summary:  Calculate the Mean curvature of a given surface (x,y,z).

gm = zeros(size(z));
[xu,xv]     =   gradient(x);
[xuu,xuv]   =   gradient(xu);
[xvu,xvv]   =   gradient(xv);

[yu,yv]     =   gradient(y);
[yuu,yuv]   =   gradient(yu);
[yvu,yvv]   =   gradient(yv);

[zu,zv]     =   gradient(z);
[zuu,zuv]   =   gradient(zu);
[zvu,zvv]   =   gradient(zv);

Xu(:,:,1) = xu;
Xu(:,:,2) = yu;
Xu(:,:,3) = zu;

Xv(:,:,1) = xv;
Xv(:,:,2) = yv;
Xv(:,:,3) = zv;

Xuu(:,:,1) = xuu;
Xuu(:,:,2) = yuu;
Xuu(:,:,3) = zuu;

Xuv(:,:,1) = xuv;
Xuv(:,:,2) = yuv;
Xuv(:,:,3) = zuv;

Xvv(:,:,1) = xvv;
Xvv(:,:,2) = yvv;
Xvv(:,:,3) = zvv;

E = dot(Xu,Xu,3);
F           =   dot(Xu,Xv,3);
G           =   dot(Xv,Xv,3);
m           =   cross(Xu,Xv,3);
temp(:,:,1) = sqrt(sum(m.*m,3));
temp(:,:,2) = temp(:,:,1);
temp(:,:,3) = temp(:,:,1);
n           =   m./temp;
L           =   dot(Xuu,n,3);
M           =   dot(Xuv,n,3);
N           =   dot(Xvv,n,3);
gm          =   ((E.*N)+(G.*L)-(2.*F.*M))./(2.*(E.*G - F.^2));

dim = size(z);
samc = 1/ (dim(1) * dim(2)) * sum (gm(:).^2);

但我有一些基本问题。 首先,我的点是点云,它们只有 X、Y 和 Z。例如:

 32512035.2100000   5401399.57000000    346.880000000000
32512044.0300000    5401399.54000000    346.850000000000
32512046.8900000    5401399.55000000    346.780000000000
32512049.7800000    5401399.53000000    346.860000000000
32512052.6900000    5401399.53000000    346.700000000000
32512054.0300000    5401399.53000000    346.780000000000
32512055.6900000    5401399.57000000    346.810000000000
32512063.1200000    5401399.54000000    347.800000000000
32512074.2300000    5401399.55000000    346.440000000000
32512093.1200000    5401399.54000000    346.660000000000

在这个函数中我遇到了以下错误:

   Error in ==> mcurvature_vec at 28
[xu,xv]     =   gradient(x);

与X、Y、Z的维度有关。 由于我的数据是仅包含 X、Y 和 Z 的点云,是一种计算每个点的曲率的方法吗?

【问题讨论】:

    标签: matlab gradient curve-fitting curve


    【解决方案1】:

    如果长度相同,则调用具有3个变量的函数以查看 mcurvature_vec 的行为方式。似乎它期望 x y z 如 x = rand(1, 100);比如……

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多