主要内容

几何图形3D

3-D geometric transformation object

Description

A几何图形3Dobject defines a custom 3-D geometric transformation using point-wise mapping functions.

Creation

Description

example

tform= geometricTransform3d(inverseFcn)creates a几何图形3Dobject and sets the value of inverse mapping function property,InverseFcntoinverseFcn.

tform= geometricTransform3d(inverseFcn,forwardFcn)also sets the value of forward mapping function property,ForwardFcntoforwardFcn.

Properties

expand all

逆映射函数, specified as a function handle. The function must accept and return coordinates as ann-by-3 numeric matrix representing the packed (x,y,z) coordinates ofn点。

For more information about function handles, seeCreate Function Handle.

Example:ifcn = @(xyz) [xyz(:,1).^2,xyz(:,2).^2,xyz(:,3).^2];

Forward mapping function, specified as a function handle. The function must accept and return coordinates as ann-by-3 numeric matrix representing the packed (x,y,z) coordinates ofn点。

For more information about function handles, seeCreate Function Handle.

Example:ffcn = @(xyz) [sqrt(xyz(:,1)),sqrt(xyz(:,2)),sqrt(xyz(:,3))];

Object Functions

transformPointsForward Apply forward geometric transformation
transformPointsInverse 应用反向几何变换

Examples

collapse all

指定packed (x,y,z) coordinates of five input points. The packed coordinates are stored as a 5-by-3 matrix, where the first, second, and third columns contain thex- ,,y- ,,andz-坐标分别。

XYZ = [5 25 20;10 5 25;15 10 5;20 15 10;25 20 15];

定义一个接收并返回包装中点的逆映射函数(x,y,z) format.

inverseFcn = @(c) [c(:,1)+c(:,2),c(:,1)-c(:,2),c(:,3).^2];

Create a 3-D geometric transformation object,tform,该存储此逆映射函数。

tform = geometrictransform3d(inverseFCN)
tform =具有属性的deemogetrictransform3d:inversefcn: @(c)[c(::,1)+c(:,2),c(:,1)-c(:,2),c(:,3)。^2] forwardfcn:[]维度:3

将此3-D几何转换的反变形应用于输入点。

UVW = transformPointsInverse(tform,XYZ)
UVW =5×3-20 400 5 625 25 5 25 35 5 100 45 5 225

指定x- ,,y- and thez-coordinate vectors of five points to transform.

x = [3 5 7 9 11];y = [2 4 6 8 10];z = [5 9 13 17 21];

Define the inverse and forward mapping functions that accept and return points in packed (x,y,z) format.

inversefcn = @(c)[c(:,1)。^2,c(:,2)。^2,c(:,3)。^2];forwardfcn = @(c)[sqrt(c(::,1)),sqrt(c(c(:,2)),sqrt(c(c(:,3))]];

Create a 3-D geometric transformation object,tform, that stores these inverse and forward mapping functions.

tform= geometricTransform3d(inverseFcn,forwardFcn)
tform= geometricTransform3d with properties: InverseFcn: @(c)[c(:,1).^2,c(:,2).^2,c(:,3).^2] ForwardFcn: @(c)[sqrt(c(:,1)),sqrt(c(:,2)),sqrt(c(:,3))] Dimensionality: 3

将此3-D几何转换的反变形应用于输入点。

[u,v,w] = transformPointsInverse(tform,x,y,z)
u =1×59 25 49 81 121
v =1×54 16 36 64 100
w =1×525 81 169 289 441

Apply the forward geometric transform to the transformed pointsu,v, 和w.

[x,y,z] = transformPointsForward(tform,u,v,w)
x =1×53 5 7 9 11
y =1×52 4 6 8 10
z =1×55 9 13 17 21

定义对水平轴进行反射的反映射函数。该功能必须接受并返回包装(x,y,z)坐标,其中第一,第二和第三列包含x- ,,y- ,,andz- 坐标分别。

inversefcn = @(xyz)[xyz(:1),-xyz(:2),xyz(::3)];

Create a 3-D geometric transformation object,tform,该存储此逆映射函数。

tform = geometrictransform3d(inverseFCN)
tform = with属性的几何图:inversefcn: @(xyz)[xyz(:,1), -  xyz(:,2),xyz(:3)] forwardfcn:[]维度:[]维度:3

Load and display an MRI volume to be transformed.

s = load('MRI'); mriVolume = squeeze(s.D);

Useimwarpto apply the inverse geometric transform to the input MRI volume.

[mriVolumeTransformed] = imwarp(mriVolume,tform,'nearest',“平滑鞋”,true);

显示输入MRI量的图像切片作为蒙太奇。

montage(mriVolume,'Size',[4 8],'背景颜色','w') title('Image Slices from 3-D MRI','FontSize',14)

图包含一个轴。来自3-D MRI的标题图像切片的轴包含类型图像的对象。

显示从变换的MRI体积作为蒙太奇的图像切片。转换的图像切片是输入图像切片的反射x-axis.

蒙太奇(Mrivolumetransform,'Size',[4 8],'背景颜色','w') title('Image Slices from Inverse Geometric Transformation of 3-D MRI','FontSize',14)

图包含一个轴。The axes with title Image Slices from Inverse Geometric Transformation of 3-D MRI contains an object of type image.

Introduced in R2018b