# 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.

## 2-D and 3-D Geometric Transformation Process Overview

To perform a 2-D or 3-D geometric transformation, follow this process:

1. Define Parameters of the Geometric Transformation — To do this, you must create an `affine2d`, `projective2d`, or `affine3d` geometric transformation object. The toolbox provides several ways to create a geometric transformation object.

2. Perform the Geometric Transformation— To do this, you pass the image to be transformed and the geometric transformation object to the `imwarp` function.

The following figure illustrates this process.

### Define Parameters of the Geometric Transformation

Before you can perform a geometric transformation, you must first define the parameters of the transformation in a geometric transformation object. The following sections describe two ways you can do this:

#### Using a Transformation Matrix

If you know the transformation matrix for the geometric transformation you want to perform, you can create a geometric transformation object directly, passing the transformation matrix in the constructor. For more information about creating a transformation matrix, see Matrix Representation of Geometric Transformations.

The following example defines the transformation matrix for a translation and creates an `affine2d` geometric transformation object.

```xform = [ 1 0 0 0 1 0 40 40 1 ]; tform_translate = affine2d(xform); ```
```tform_translate = affine2d with properties: T: [3x3 double] Dimensionality: 2```

#### Using Sets of Points

You can create a geometric transformation object by passing two sets of control point pairs to the `fitgeotrans` function. The `fitgeotrans` function estimates the transformation from these points and returns one of the geometric transformation objects.

Different transformations require a varying number of points. For example, affine transformations require three non-collinear points in each image (a triangle) and projective transformations require four points (a quadrilateral).

This example passes two sets of control points to `fitgeotrans`, which returns an `affine2d` geometric transformation object.

```movingPoints = [11 11;21 11; 21 21]; fixedPoints = [51 51;61 51;61 61]; tform_cpp = fitgeotrans(movingPoints,fixedPoints,'affine') ```
```tform_cpp = affine2d with properties: T: [3x3 double] Dimensionality: 2```

### Perform the Geometric Transformation

Once you define the transformation in a geometric transformation object, you can perform the transformation by calling the `imwarp` function, passing it the image to be transformed and a geometric transformation object. `imwarp` performs the specified transformation on the coordinates of the input image and creates an output image. To see an illustration of this process, see Perform Simple 2-D Translation Transformation.