# Documentation

### This is machine translation

Translated by
Mouseover text to see original. Click the button below to return to the English verison of the page.

# images.geotrans.PiecewiseLinearTransformation2D class

Package: images.geotrans

2-D piecewise linear geometric transformation

## Description

A `PiecewiseLinearTransformation2D` object encapsulates a 2-D piecewise linear geometric transformation.

You can create a `PiecewiseLinearTransformation2D` object using the following methods:

• `fitgeotrans` — Returns a `PiecewiseLinearTransformation2D` object that maps control point pairs using a piecewise linear transformation

• The `PiecewiseLinearTransformation2D` class constructor

## Construction

`tform = images.geotrans.PiecewiseLinearTransformation2D(movingPoints,fixedPoints)` creates a `PiecewiseLinearTransformation2D` object given m-by-2 matrices `movingPoints` and `fixedPoints`, which define matched control points in the moving and fixed images, respectively. The piecewise linear transformation creates a mapping by breaking up the plane into regions and using a different affine transformation to map control points in each region.

## Input Arguments

expand all

x- and y-coordinates of control points in the moving image, specified as an m-by-2 matrix.

Data Types: `double` | `single`

x- and y-coordinates of control points in the fixed image, specified as an m-by-2 matrix.

Data Types: `double` | `single`

## Properties

expand all

Describes the dimensionality of the geometric transformation for both input and output points.

## Methods

 images.geotrans.PiecewiseLinearTransformation2D.outputLimits Find output limits of geometric transformation images.geotrans.PiecewiseLinearTransformation2D.transformPointsInverse Apply inverse geometric transformation

## Copy Semantics

Value. To learn how value classes affect copy operations, see Copying Objects (MATLAB) in the MATLAB® documentation.

## Examples

expand all

Fit a piecewise linear transformation to a set of fixed and moving control points that are actually related by a single global affine2d transformation across the domain.

Create a 2D affine transformation.

```theta = 10; tformAffine = affine2d([cosd(theta) -sind(theta) 0; sind(theta) cosd(theta) 0; 0 0 1])```
```tformAffine = affine2d with properties: T: [3x3 double] Dimensionality: 2 ```

Arbitrarily choose 6 pairs of control points.

`fixedPoints = [10 20; 10 5; 2 3; 0 5; -5 3; -10 -20];`

Apply forward geometric transformation to map fixed points to obtain effect of fixed and moving points that are related by some geometric transformation.

`movingPoints = transformPointsForward(tformAffine,fixedPoints)`
```movingPoints = 13.3210 17.9597 10.7163 3.1876 2.4906 2.6071 0.8682 4.9240 -4.4031 3.8227 -13.3210 -17.9597```

Estimate piecewise linear transformation that maps `movingPoints` to `fixedPoints`.

`tformPiecewiseLinear = images.geotrans.PiecewiseLinearTransformation2D(movingPoints,fixedPoints)`
```tformPiecewiseLinear = PiecewiseLinearTransformation2D with properties: Dimensionality: 2```

Verify the fit of our `PiecewiseLinearTransformation2D` object at the control points.

```movingPointsComputed = transformPointsInverse(tformPiecewiseLinear,fixedPoints); errorInFit = hypot(movingPointsComputed(:,1)-movingPoints(:,1),... movingPointsComputed(:,2)-movingPoints(:,2))```
```errorInFit = 1.0e-15 * 0 0 0.4441 0 0 0```