Main Content

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

pctransform

説明

ptCloudOut = pctransform(ptCloudIn,tform) は、指定された 3 次元アフィン変換 tform を点群 ptCloudIn に適用します。変換は、剛体変換、相似変換、またはアフィン変換にすることができます。

ptCloudOut = pctransform(ptCloudIn,D) は変位場 D を点群に適用します。変位場を使用する点群変換は、点群の各点を基準に平行移動を定義します。

すべて折りたたむ

点群を読み取ります。

ptCloud = pcread('teapot.ply');

点群をプロットします。

figure
pcshow(ptCloud)
xlabel('X')
ylabel('Y')
zlabel('Z')

Figure contains an axes object. The axes object with xlabel X, ylabel Y contains an object of type scatter.

z 軸に沿って 45 度の回転を行う変換オブジェクトを作成します。

rotationAngles = [0 0 45];
translation = [0 0 0];
tform = rigidtform3d(rotationAngles,translation);

点群を変換します。

ptCloudOut = pctransform(ptCloud,tform);

変換後の点群をプロットします。

figure
pcshow(ptCloudOut)
xlabel('X')
ylabel('Y')
zlabel('Z')

Figure contains an axes object. The axes object with xlabel X, ylabel Y contains an object of type scatter.

この例では、剛体変換 (回転) と非剛体変換 (せん断) を 3 次元点群に適用します。

点群をワークスペースに読み取ります。

ptCloud = pcread('teapot.ply');

元の 3 次元点群をプロットします。

figure1 = figure;
axes1 = axes(Parent=figure1);
pcshow(ptCloud,Parent=axes1,AxesVisibility='on'); 
xlabel('X');
ylabel('Y');
zlabel('Z');
title('3-D Point Cloud',FontSize=14)

Figure contains an axes object. The axes object with title 3-D Point Cloud, xlabel X, ylabel Y contains an object of type scatter.

3 次元点群の回転

z 軸に沿って 45 度の回転を定義する剛体変換オブジェクトを作成します。

rotationAngles = [0 0 45];
translation = [0 0 0];
tform = rigidtform3d(rotationAngles,translation);

点群を変換します。

ptCloudOut1 = pctransform(ptCloud,tform);

回転させた点群をプロットします。

figure2 = figure;
axes2 = axes(Parent=figure2);
pcshow(ptCloudOut1,Parent=axes2,AxesVisibility='on');
xlabel('X');
ylabel('Y');
zlabel('Z');
title({'Rotation of 3-D Point Cloud'},FontSize=14)

Figure contains an axes object. The axes object with title Rotation of 3-D Point Cloud, xlabel X, ylabel Y contains an object of type scatter.

3 次元点群のせん断

x 軸に沿ってせん断を定義するアフィン変換オブジェクトを作成します。

A = [1 0.75 0.75 0; ...
     0   1    0  0; ...
     0   0    1  0; ...
     0   0    0  1];
tform = affinetform3d(A);

点群を変換します。

ptCloudOut2 = pctransform(ptCloud,tform);

変換後の点群をプロットします。

figure3 = figure;
axes3 = axes(Parent=figure3);
pcshow(ptCloudOut2,Parent=axes3,AxesVisibility='on');
xlabel('X');
ylabel('Y');
zlabel('Z');
title({'Shearing of 3-D Point Cloud'},FontSize=14)

Figure contains an axes object. The axes object with title Shearing of 3-D Point Cloud, xlabel X, ylabel Y contains an object of type scatter.

点群をワークスペースに読み取ります。

ptCloud = pcread('teapot.ply');

点群と同じサイズの変位場 D を作成します。

D = zeros(size(ptCloud.Location));

最初の半分の点の x 軸に沿った変位場の値を 7 に設定します。

pthalf = ptCloud.Count/2;
D(1:pthalf,1) = 7;

pointCloud メソッドfindNeighborsInRadiusを使用して、関心領域 (ROI) 内の点のインデックスを抽出します。ROI 内の点の x 軸、y 軸、および z 軸に沿った変位場の値をそれぞれ、4、4、-2 に設定します。

indices = findNeighborsInRadius(ptCloud,[0 0 3.1],1.5);
D(indices,1:2) = 4;
D(indices,3) = -2;

変位場を使用して点群を変換します。

ptCloudOut = pctransform(ptCloud,D);

元の点群と変換後の点群を表示します。

figure
pcshow(ptCloud)
xlabel('X');
ylabel('Y');
zlabel('Z');
title('Original 3-D Point Cloud')

Figure contains an axes object. The axes object with title Original 3-D Point Cloud, xlabel X, ylabel Y contains an object of type scatter.

figure
pcshow(ptCloudOut)
xlabel('X');
ylabel('Y');
zlabel('Z');
title('Transformed 3-D Point Cloud Using Displacement Field')

Figure contains an axes object. The axes object with title Transformed 3-D Point Cloud Using Displacement Field, xlabel X, ylabel Y contains an object of type scatter.

入力引数

すべて折りたたむ

点群。pointCloud オブジェクトとして指定します。

3 次元幾何学的変換。rigidtform3d オブジェクト、simtform3d オブジェクト、または affinetform3d オブジェクトとして指定します。アフィン 3 次元入力 tform の設定方法の詳細については、変換行列の指定を参照してください。

変位場。M 行 3 列の配列または M x N x 3 の配列として指定します。変位場は、点群の各点の平行移動の大きさと方向を指定する一連の変位ベクトルです。変位場のサイズは、pointCloud オブジェクトの Location プロパティと同じサイズでなければなりません。

データ型: single | double

出力引数

すべて折りたたむ

変換後の点群。pointCloud オブジェクトとして返されます。変換は、点およびその法線ベクトルの座標軸に適用されます。

拡張機能

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

GPU コード生成
GPU Coder™ を使用して NVIDIA® GPU のための CUDA® コードを生成します。

バージョン履歴

R2015a で導入

すべて展開する