このページの内容は最新ではありません。最新版の英語を参照するには、ここをクリックします。
pctransform
3 次元点群の変換
説明
は、指定された 3 次元アフィン変換 ptCloudOut
= pctransform(ptCloudIn
,tform
)tform
を点群 ptCloudIn
に適用します。変換は、剛体変換、相似変換、またはアフィン変換にすることができます。
は変位場 ptCloudOut
= pctransform(ptCloudIn
,D
)D
を点群に適用します。変位場を使用する点群変換は、点群の各点を基準に平行移動を定義します。
例
剛体変換を使用した 3 次元点群の回転
点群を読み取ります。
ptCloud = pcread('teapot.ply');
点群をプロットします。
figure pcshow(ptCloud) xlabel('X') ylabel('Y') zlabel('Z')
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')
3 次元点群の剛体変換と非剛体変換
この例では、剛体変換 (回転) と非剛体変換 (せん断) を 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)
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)
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)
変位場を使用した点群変換
点群をワークスペースに読み取ります。
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 pcshow(ptCloudOut) xlabel('X'); ylabel('Y'); zlabel('Z'); title('Transformed 3-D Point Cloud Using Displacement Field')
入力引数
ptCloudIn
— 点群
pointCloud
オブジェクト
点群。pointCloud
オブジェクトとして指定します。
tform
— 3 次元幾何学的変換
rigidtform3d
オブジェクト | simtform3d
オブジェクト | affinetform3d
オブジェクト
3 次元幾何学的変換。rigidtform3d
オブジェクト、simtform3d
オブジェクト、または affinetform3d
オブジェクトとして指定します。アフィン 3 次元入力 tform
の設定方法の詳細については、変換行列の指定を参照してください。
D
— 変位場
M 行 3 列の行列 | M x N x 3 の配列
変位場。M 行 3 列の配列または M x N x 3 の配列として指定します。変位場は、点群の各点の平行移動の大きさと方向を指定する一連の変位ベクトルです。変位場のサイズは、pointCloud
オブジェクトの Location
プロパティと同じサイズでなければなりません。
データ型: single
| double
出力引数
ptCloudOut
— 変換後の点群
pointCloud
オブジェクト
変換後の点群。pointCloud
オブジェクトとして返されます。変換は、点およびその法線ベクトルの座標軸に適用されます。
拡張機能
C/C++ コード生成
MATLAB® Coder™ を使用して C および C++ コードを生成します。
GPU コード生成
GPU Coder™ を使用して NVIDIA® GPU のための CUDA® コードを生成します。
バージョン履歴
R2015a で導入R2022b: 新しい幾何学的変換オブジェクトをサポート
R2022b 以降、Computer Vision Toolbox™ のほとんどの関数は、左から乗算する規則を使用して幾何学的変換を作成および実行します。このため、引数 tform
を、左から乗算する規則を使用する rigidtform3d
オブジェクト、simtform3d
オブジェクト、または affinetform3d
オブジェクトとして指定できるようになりました。
tform
を rigid3d
オブジェクトまたは affine3d
オブジェクトとして指定することはできますが、これらのオブジェクトは右から乗算する規則を使用するため、推奨されません。左から乗算する新しい幾何学的変換オブジェクトに切り替えることで、幾何学的変換のワークフローを効率化できます。詳細については、Migrate Geometric Transformations to Premultiply Conventionを参照してください。
参考
オブジェクト
関数
pcplayer
|pcshow
|pcwrite
|pcread
|pcmerge
|pcdownsample
|pcfitplane
|pcdenoise
|pcregistericp
|pccat
|pcalign
MATLAB コマンド
次の MATLAB コマンドに対応するリンクがクリックされました。
コマンドを MATLAB コマンド ウィンドウに入力して実行してください。Web ブラウザーは MATLAB コマンドをサポートしていません。
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)