Operators

vector_to_similarity (Operator)

Name

vector_to_similarity — Approximate an similarity transformation from point correspondences.

Signature

vector_to_similarity( : : Px, Py, Qx, Qy : HomMat2D)

Description

vector_to_similarity approximates a similarity transformation, i.e., a transformation consisting of a uniform scaling, a rotation, and a translation, from at least two point correspondences and returns it as the homogeneous transformation matrix HomMat2D. The matrix consists of 3 components: a scaling matrix S with identical scaling in the x and y directions, a rotation matrix R, and a translation vector t (also see hom_mat2d_scale, hom_mat2d_rotate, and hom_mat2d_translate):

```                              / 1 0 tx \   / R00 R01 0 \   / S 0 0 \
HomMat2D  =  | R*S  t |  =  | 0 1 ty | * | R10 R11 0 | * | 0 S 0 |  =  H(t) * H(R) * H(S)
| 0 0  1 |     \ 0 0 1  /   \  0   0  1 /   \ 0 0 1 /

```

The point correspondences are passed in the tuples (Px, Py) and (Qx,Qy), where corresponding points must be at the same index positions in the tuples. If more than two point correspondences are passed, the transformation is overdetermined. In this case, the returned transformation is the transformation that minimizes the distances between the original points (Px,Py) and the transformed points (Qx,Qy), as described in the following equation (points as homogeneous vectors):

```             || / Qx[i] \                / Px[i] \ ||^2
sum of all  || | Qy[i] |  -  HomMat2D * | Py[i] | ||  =  minimum
|| \  1    /                \  1    / ||
```

HomMat2D can be used directly with operators that transform data using affine transformations, e.g., affine_trans_image.

Attention

It should be noted that homogeneous transformation matrices refer to a general right-handed mathematical coordinate system. If a homogeneous transformation matrix is used to transform images, regions, XLD contours, or any other data that has been extracted from images, the row coordinates of the transformation must be passed in the x coordinates, while the column coordinates must be passed in the y coordinates. Consequently, the order of passing row and column coordinates follows the usual order (Row,Column). This convention is essential to obtain a right-handed coordinate system for the transformation of iconic data, and consequently to ensure in particular that rotations are performed in the correct mathematical direction.

Furthermore, it should be noted that if a homogeneous transformation matrix is used to transform images, regions, XLD contours, or any other data that has been extracted from images, it is assumed that the origin of the coordinate system of the homogeneous transformation matrix lies in the upper left corner of a pixel. The image processing operators that return point coordinates, however, assume a coordinate system in which the origin lies in the center of a pixel. Therefore, to obtain a consistent homogeneous transformation matrix, 0.5 must be added to the point coordinates before computing the transformation.

Parallelization

• Multithreading type: reentrant (runs in parallel with non-exclusive operators).
• Processed without parallelization.

Parameters

Px (input_control)  point.x-array (real)

X coordinates of the original points.

Py (input_control)  point.y-array (real)

Y coordinates of the original points.

Qx (input_control)  point.x-array (real)

X coordinates of the transformed points.

Qy (input_control)  point.y-array (real)

Y coordinates of the transformed points.

HomMat2D (output_control)  hom_mat2d (real)

Output transformation matrix.