main Content

pctransform

Transform 3-D point cloud

描述

例子

ptcloudout= pctransform(ptCloudIn,,,,tform应用指定的3-D仿射变换,tformto the point cloud,ptCloudIn。转换可以是刚性或非辅助变换。

例子

ptcloudout= pctransform(ptCloudIn,,,,d应用位移字段d到点云。使用位移字段的点云转换相对于点云中的每个点定义了翻译。

例子

全部收缩

阅读点云。

ptCloud = pcread('茶壶);

绘制点云。

图PCSHOW(PTCLOUD)XLABEL('X')ylabel('Y')Zlabel('Z'

图包含一个轴对象。轴对象包含类型散点的对象。

Create a transform object with a 45 degree rotation along the z-axis.

theta = pi/4;rot = [cos(theta)sin(theta)0;...-sin(theta) cos(theta) 0;...0 0 1];trans = [0,0,0];tform = rigid3d(rot,trans);

转换点云。

ptcloudout = pctransform(ptcloud,tform);

绘制转换的点云。

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

图包含一个轴对象。轴对象包含类型散点的对象。

This example shows affine transformation of a 3-D point cloud. The specified forward transform can be a rigid or nonrigid transform. The transformations shown includes rotation (rigid transform) and shearing (nonrigid transform) of the input point cloud.

Read a point cloud into the workspace.

ptCloud = pcread('茶壶);

3-D点云的旋转

Create an affine transform object that defines a 45 degree rotation along thez-轴。

a = [cos(pi/4)sin(pi/4)0 0;...-sin(pi/4)cos(pi/4)0 0;...0 0 1 0;...0 0 0 1]; tform = affine3d(A);

转换点云。

ptcloudout1 = pctransform(ptCloud,tform);

3-D点云的剪切

创建一个仿射转换对象,该对象定义沿着X-轴。

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

转换点云。

ptCloudout2 = pctransform(ptcloud,tform);

显示原始和仿射转换的3-D点云

绘制原始的3-D点云。

figure1 = figure(“窗口”,,,,'普通的');axes1 =轴(轴'Parent',,,,figure1); pcshow(ptCloud,'Parent',axes1);Xlabel('X');ylabel('Y');Zlabel('Z');title(“ 3-D点云”,,,,'字体大小',14)

图包含一个轴对象。带有标题3-D点云的轴对象包含类型散点的对象。

%绘制旋转和剪切仿射转化的3-D点云。figure2 = figure(“窗口”,,,,'普通的');axes2 =轴(轴'Parent',图2);pcshow(ptcloudout1,'Parent',axes2);Xlabel('X');ylabel('Y');Zlabel('Z');title({'Rotation of 3-D Point Cloud'},'字体大小',14)

图包含一个轴对象。The axes object with title Rotation of 3-D Point Cloud contains an object of type scatter.

图3 =图(“窗口”,,,,'普通的');axes3 = axes('Parent',,,,figure3); pcshow(ptCloudOut2,'Parent',,,,axes3); xlabel('X');ylabel('Y');Zlabel('Z');title({'Shearing of 3-D Point Cloud'},'字体大小',14)

图包含一个轴对象。带有3-D点云标题剪切的轴对象包含类型散点的对象。

Read a point cloud into the workspace.

ptCloud = pcread('茶壶);

创建一个位移字段d与点云相同的大小。

d = zeros(size(ptcloud.location));

将位移字段值沿X-axis for the first half of the points to 7.

pthalf = ptcloud.count/2;d(1:pthalf,1)= 7;

Extract the indices of points within a region-of-interest (ROI) using thepointCloud方法Findneighborsinradius。将位移字段值沿X-,y-, 和z- ROI内的点分别为4、4和-2。

indices = findneighborsinradius(ptcloud,[0 0 3.1],1.5);d(指数,1:2)= 4;d(指数,3)= -2;

使用位移字段转换点云。

ptcloudout = pctransform(ptcloud,d);

显示原始和转换的点云。

图PCSHOW(PTCLOUD)XLABEL('X');ylabel('Y');Zlabel('Z');title(“原始3-D点云”

图包含一个轴对象。带有标题原始3-D点云的轴对象包含类型散点的对象。

figure pcshow(ptCloudOut) xlabel('X');ylabel('Y');Zlabel('Z');title(“使用位移字段转换3-D点云”

图包含一个轴对象。The axes object with title Transformed 3-D Point Cloud Using Displacement Field contains an object of type scatter.

输入参数

全部收缩

点云,,,,specified as apointCloud目的。

3-D几何变换,,,,specified as a刚性3D对象或一个仿射3D目的。看define Transformation Matrix有关如何设置仿射3-D的详细信息tform输入。

位移字段,指定为m-by-3 or anm-by-n-by-3 array. The displacement field is a set of displacement vectors that specify the magnitude and direction of translation for each point in the point cloud. The size of the displacement field must be the same as the size of the地点property of thepointCloud目的。

数据类型:单身的|双倍的

输出参数

全部收缩

转换点云,返回pointCloud目的。The transformation applies to the coordinates of points and their normal vectors.

扩展功能

C/C ++代码生成
Generate C and C++ code using MATLAB® Coder™.

GPU代码生成
Generate CUDA® code for NVIDIA® GPUs using GPU Coder™.

版本历史记录

Introduced in R2015a