Main Content

このページの内容は最新ではありません。最新版の英語を参照するには、ここをクリックします。

pcnormals

説明

normals = pcnormals(ptCloud) は、入力 ptCloud の各点の法線を格納する行列を返します。この関数では 6 つの近傍点を使用して局所平面への適合を行い各法線ベクトルを決定します。

normals = pcnormals(ptCloud,k) では、局所平面への適合に使用される点数 k を追加で指定します。関数は、最初の構文で説明されている 6 つの近傍点ではなく、この値を使用します。

すべて折りたたむ

点群を読み込みます。

load('object3d.mat');

法線ベクトルを推定します。

normals = pcnormals(ptCloud);

figure
pcshow(ptCloud)
title('Estimated Normals of Point Cloud')
hold on

Figure contains an axes object. The axes object with title Estimated Normals of Point Cloud contains an object of type scatter.

x = ptCloud.Location(1:10:end,1:10:end,1);
y = ptCloud.Location(1:10:end,1:10:end,2);
z = ptCloud.Location(1:10:end,1:10:end,3);
u = normals(1:10:end,1:10:end,1);
v = normals(1:10:end,1:10:end,2);
w = normals(1:10:end,1:10:end,3);

法線ベクトルをプロットします。

quiver3(x,y,z,u,v,w);
hold off

Figure contains an axes object. The axes object with title Estimated Normals of Point Cloud contains 2 objects of type scatter, quiver.

法線を反転してセンサーの位置を指します。この手順が必要になるのは、表面の内向きか、外向きかを決定する場合だけです。センサー中央は xyz 座標で設定されます。

sensorCenter = [0,-0.3,0.3]; 
for k = 1 : numel(x)
   p1 = sensorCenter - [x(k),y(k),z(k)];
   p2 = [u(k),v(k),w(k)];
   % Flip the normal vector if it is not pointing towards the sensor.
   angle = atan2(norm(cross(p1,p2)),p1*p2');
   if angle > pi/2 || angle < -pi/2
       u(k) = -u(k);
       v(k) = -v(k);
       w(k) = -w(k);
   end
end

調整された法線をプロットします。

figure
pcshow(ptCloud)
title('Adjusted Normals of Point Cloud')
hold on
quiver3(x, y, z, u, v, w);
hold off

Figure contains an axes object. The axes object with title Adjusted Normals of Point Cloud contains 2 objects of type scatter, quiver.

入力引数

すべて折りたたむ

点群を格納するオブジェクト。pointCloud オブジェクトとして返されます。

局所平面への適合に使用される点数。3 以上の整数として指定します。この値を大きくすると精度は上がりますが、計算時間が遅くなります。k を指定しない場合、関数は 6 つの近傍点を使用して局所平面への適合を行い各法線ベクトルを決定します。

出力引数

すべて折りたたむ

局所平面への適合に使用される法線。M 行 3 列または M×N×3 の行列として返されます。法線ベクトルは、k の値によって定義された近傍の数を使用して局所的に計算されます。k が入力でない場合、6 つの近傍点が使用されます。各法線ベクトルの方向は、点の取得方法に基づいて設定できます。点群の法線の推定の例は、法線ベクトルがセンサーに向かっているときの方向の設定方法を示しています。

参照

[1] Hoppe, H., T. DeRose, T. Duchamp, J. Mcdonald, and W. Stuetzle. "Surface Reconstruction from Unorganized Points". Computer Graphics (SIGGRAPH 1992 Proceedings). 1992, pp. 71–78.

拡張機能

C/C++ コード生成
MATLAB® Coder™ を使用して C および C++ コードを生成します。

バージョン履歴

R2015b で導入