# Direct linear transformation

Direct linear transformation (DLT) is an algorithm which solves a set of variables from a set of similarity relations:

${\displaystyle \mathbf {x} _{k}\propto \mathbf {A} \,\mathbf {y} _{k}}$   for ${\displaystyle \,k=1,\ldots ,N}$

where ${\displaystyle \mathbf {x} _{k}}$ and ${\displaystyle \mathbf {y} _{k}}$ are known vectors, ${\displaystyle \,\propto }$ denotes equality up to an unknown scalar multiplication, and ${\displaystyle \mathbf {A} }$ is a matrix (or linear transformation) which contains the unknowns to be solved.

This type of relation appears frequently in projective geometry. Practical examples include the relation between 3D points in a scene and their projection onto the image plane of a pinhole camera,[1] and homographies.

## Introduction

An ordinary system of linear equations

${\displaystyle \mathbf {x} _{k}=\mathbf {A} \,\mathbf {y} _{k}}$   for ${\displaystyle \,k=1,\ldots ,N}$

can be solved, for example, by rewriting it as a matrix equation ${\displaystyle \mathbf {X} =\mathbf {A} \,\mathbf {Y} }$ where matrices ${\displaystyle \mathbf {X} }$ and ${\displaystyle \mathbf {Y} }$ contain the vectors ${\displaystyle \mathbf {x} _{k}}$ and ${\displaystyle \mathbf {y} _{k}}$ in their respective columns. Given that there exists a unique solution, it is given by

${\displaystyle \mathbf {A} =\mathbf {X} \,\mathbf {Y} ^{T}\,(\mathbf {Y} \,\mathbf {Y} ^{T})^{-1}.}$

Solutions can also be described in the case that the equations are over or under determined.

What makes the direct linear transformation problem distinct from the above standard case is the fact that the left and right sides of the defining equation can differ by an unknown multiplicative factor which is dependent on k. As a consequence, ${\displaystyle \mathbf {A} }$ cannot be computed as in the standard case. Instead, the similarity relations are rewritten as proper linear homogeneous equations which then can be solved by a standard method. The combination of rewriting the similarity equations as homogeneous linear equations and solving them by standard methods is referred to as a direct linear transformation algorithm or DLT algorithm. DLT is attributed to Ivan Sutherland. [2]

## Example

Suppose that ${\displaystyle k\in \{1,...,N\}}$. Let ${\displaystyle \mathbf {x} _{k}=(x_{1k},x_{2k})\in \mathbb {R} ^{2}}$ and ${\displaystyle \mathbf {y} _{k}=(y_{1k},y_{2k},y_{3k})\in \mathbb {R} ^{3}}$ be two known vectors, and we want to find the ${\displaystyle 2\times 3}$ matrix ${\displaystyle \mathbf {A} }$ such that

${\displaystyle \alpha _{k}\,\mathbf {x} _{k}=\mathbf {A} \,\mathbf {y} _{k}}$

where ${\displaystyle \alpha _{k}\neq 0}$ is the unknown scalar factor related to equation k.

To get rid of the unknown scalars and obtain homogeneous equations, define the anti-symmetric matrix

${\displaystyle \mathbf {H} ={\begin{pmatrix}0&-1\\1&0\end{pmatrix}}}$

and multiply both sides of the equation with ${\displaystyle \mathbf {x} _{k}^{T}\,\mathbf {H} }$ from the left

{\displaystyle {\begin{aligned}(\mathbf {x} _{k}^{T}\,\mathbf {H} )\,\alpha _{k}\,\mathbf {x} _{k}&=(\mathbf {x} _{k}^{T}\,\mathbf {H} )\,\mathbf {A} \,\mathbf {y} _{k}\\\alpha _{k}\,\mathbf {x} _{k}^{T}\,\mathbf {H} \,\mathbf {x} _{k}&=\mathbf {x} _{k}^{T}\,\mathbf {H} \,\mathbf {A} \,\mathbf {y} _{k}\end{aligned}}}

Since ${\displaystyle \mathbf {x} _{k}^{T}\,\mathbf {H} \,\mathbf {x} _{k}=0,}$ the following homogeneous equations, which no longer contain the unknown scalars, are at hand

${\displaystyle \mathbf {x} _{k}^{T}\,\mathbf {H} \,\mathbf {A} \,\mathbf {y} _{k}=0}$

In order to solve ${\displaystyle \mathbf {A} }$ from this set of equations, consider the elements of the vectors ${\displaystyle \mathbf {x} _{k}}$ and ${\displaystyle \mathbf {y} _{k}}$ and matrix ${\displaystyle \mathbf {A} }$:

${\displaystyle \mathbf {x} _{k}={\begin{pmatrix}x_{1k}\\x_{2k}\end{pmatrix}}}$,   ${\displaystyle \mathbf {y} _{k}={\begin{pmatrix}y_{1k}\\y_{2k}\\y_{3k}\end{pmatrix}}}$,   and   ${\displaystyle \mathbf {A} ={\begin{pmatrix}a_{11}&a_{12}&a_{13}\\a_{21}&a_{22}&a_{23}\end{pmatrix}}}$

and the above homogeneous equation becomes

${\displaystyle 0=a_{11}\,x_{2k}\,y_{1k}-a_{21}\,x_{1k}\,y_{1k}+a_{12}\,x_{2k}\,y_{2k}-a_{22}\,x_{1k}\,y_{2k}+a_{13}\,x_{2k}\,y_{3k}-a_{23}\,x_{1k}\,y_{3k}}$   for ${\displaystyle \,k=1,\ldots ,N.}$

This can also be written in the matrix form:

${\displaystyle 0=\mathbf {b} _{k}^{T}\,\mathbf {a} }$   for ${\displaystyle \,k=1,\ldots ,N}$

where ${\displaystyle \mathbf {b} _{k}}$ and ${\displaystyle \mathbf {a} }$ both are 6-dimensional vectors defined as

${\displaystyle \mathbf {b} _{k}={\begin{pmatrix}x_{2k}\,y_{1k}\\-x_{1k}\,y_{1k}\\x_{2k}\,y_{2k}\\-x_{1k}\,y_{2k}\\x_{2k}\,y_{3k}\\-x_{1k}\,y_{3k}\end{pmatrix}}}$   and   ${\displaystyle \mathbf {a} ={\begin{pmatrix}a_{11}\\a_{21}\\a_{12}\\a_{22}\\a_{13}\\a_{23}\end{pmatrix}}.}$

So far, we have 1 equation and 6 unknowns. A set of homogeneous equations can be written in the matrix form

${\displaystyle \mathbf {0} =\mathbf {B} \,\mathbf {a} }$

where ${\displaystyle \mathbf {B} }$ is a ${\displaystyle N\times 6}$ matrix which holds the known vectors ${\displaystyle \mathbf {b} _{k}}$ in its rows. The unknown ${\displaystyle \mathbf {a} }$ can be determined, for example, by a singular value decomposition of ${\displaystyle \mathbf {B} }$; ${\displaystyle \mathbf {a} }$ is a right singular vector of ${\displaystyle \mathbf {B} }$ corresponding to a singular value that equals zero. Once ${\displaystyle \mathbf {a} }$ has been determined, the elements of matrix ${\displaystyle \mathbf {A} }$ can rearranged from vector ${\displaystyle \mathbf {a} }$. Notice that the scaling of ${\displaystyle \mathbf {a} }$ or ${\displaystyle \mathbf {A} }$ is not important (except that it must be non-zero) since the defining equations already allow for unknown scaling.

In practice the vectors ${\displaystyle \mathbf {x} _{k}}$ and ${\displaystyle \mathbf {y} _{k}}$ may contain noise which means that the similarity equations are only approximately valid. As a consequence, there may not be a vector ${\displaystyle \mathbf {a} }$ which solves the homogeneous equation ${\displaystyle \mathbf {0} =\mathbf {B} \,\mathbf {a} }$ exactly. In these cases, a total least squares solution can be used by choosing ${\displaystyle \mathbf {a} }$ as a right singular vector corresponding to the smallest singular value of ${\displaystyle \mathbf {B} .}$

## More general cases

The above example has ${\displaystyle \mathbf {x} _{k}\in \mathbb {R} ^{2}}$ and ${\displaystyle \mathbf {y} _{k}\in \mathbb {R} ^{3}}$, but the general strategy for rewriting the similarity relations into homogeneous linear equations can be generalized to arbitrary dimensions for both ${\displaystyle \mathbf {x} _{k}}$ and ${\displaystyle \mathbf {y} _{k}.}$

If ${\displaystyle \mathbf {x} _{k}\in \mathbb {R} ^{2}}$ and ${\displaystyle \mathbf {y} _{k}\in \mathbb {R} ^{q}}$ the previous expressions can still lead to an equation

${\displaystyle 0=\mathbf {x} _{k}^{T}\,\mathbf {H} \,\mathbf {A} \,\mathbf {y} _{k}}$   for   ${\displaystyle \,k=1,\ldots ,N}$

where ${\displaystyle \mathbf {A} }$ now is ${\displaystyle 2\times q.}$ Each k provides one equation in the ${\displaystyle 2q}$ unknown elements of ${\displaystyle \mathbf {A} }$ and together these equations can be written ${\displaystyle \mathbf {B} \,\mathbf {a} =\mathbf {0} }$ for the known ${\displaystyle N\times 2\,q}$ matrix ${\displaystyle \mathbf {B} }$ and unknown 2q-dimensional vector ${\displaystyle \mathbf {a} .}$ This vector can be found in a similar way as before.

In the most general case ${\displaystyle \mathbf {x} _{k}\in \mathbb {R} ^{p}}$ and ${\displaystyle \mathbf {y} _{k}\in \mathbb {R} ^{q}}$. The main difference compared to previously is that the matrix ${\displaystyle \mathbf {H} }$ now is ${\displaystyle p\times p}$ and anti-symmetric. When ${\displaystyle p>2}$ the space of such matrices is no longer one-dimensional, it is of dimension

${\displaystyle M={\frac {p\,(p-1)}{2}}.}$

This means that each value of k provides M homogeneous equations of the type

${\displaystyle 0=\mathbf {x} _{k}^{T}\,\mathbf {H} _{m}\,\mathbf {A} \,\mathbf {y} _{k}}$   for   ${\displaystyle \,m=1,\ldots ,M}$   and for ${\displaystyle \,k=1,\ldots ,N}$

where ${\displaystyle \mathbf {H} _{m}}$ is a M-dimensional basis of the space of ${\displaystyle p\times p}$ anti-symmetric matrices.

### Example p = 3

In the case that p = 3 the following three matrices ${\displaystyle \mathbf {H} _{m}}$ can be chosen

${\displaystyle \mathbf {H} _{1}={\begin{pmatrix}0&0&0\\0&0&-1\\0&1&0\end{pmatrix}}}$,   ${\displaystyle \mathbf {H} _{2}={\begin{pmatrix}0&0&1\\0&0&0\\-1&0&0\end{pmatrix}}}$,   ${\displaystyle \mathbf {H} _{3}={\begin{pmatrix}0&-1&0\\1&0&0\\0&0&0\end{pmatrix}}.}$

In this particular case, the homogeneous linear equations can be written as

${\displaystyle \mathbf {0} =[\mathbf {x} _{k}]_{\times }\,\mathbf {A} \,\mathbf {y} _{k}}$   for   ${\displaystyle \,k=1,\ldots ,N}$

where ${\displaystyle [\mathbf {x} _{k}]_{\times }}$ is the matrix representation of the vector cross product. Notice that this last equation is vector valued; the left hand side is the zero element in ${\displaystyle \mathbb {R} ^{3}}$.

Each value of k provides three homogeneous linear equations in the unknown elements of ${\displaystyle \mathbf {A} }$. However, since ${\displaystyle [\mathbf {x} _{k}]_{\times }}$ has rank = 2, at most two equations are linearly independent. In practice, therefore, it is common to only use two of the three matrices ${\displaystyle \mathbf {H} _{m}}$, for example, for m=1, 2. However, the linear dependency between the equations is dependent on ${\displaystyle \mathbf {x} _{k}}$, which means that in unlucky cases it would have been better to choose, for example, m=2,3. As a consequence, if the number of equations is not a concern, it may be better to use all three equations when the matrix ${\displaystyle \mathbf {B} }$ is constructed.

The linear dependence between the resulting homogeneous linear equations is a general concern for the case p > 2 and has to be dealt with either by reducing the set of anti-symmetric matrices ${\displaystyle \mathbf {H} _{m}}$ or by allowing ${\displaystyle \mathbf {B} }$ to become larger than necessary for determining ${\displaystyle \mathbf {a} .}$

## References

1. ^ Abdel-Aziz, Y.I.; Karara, H.M. (2015-02-01). "Direct Linear Transformation from Comparator Coordinates into Object Space Coordinates in Close-Range Photogrammetry". Photogrammetric Engineering & Remote Sensing. 81 (2). American Society for Photogrammetry and Remote Sensing: 103–107. doi:10.14358/pers.81.2.103. ISSN 0099-1112.
2. ^ Sutherland, Ivan E. (April 1974), "Three-dimensional data input by tablet", Proceedings of the IEEE, 62 (4): 453–461, doi:10.1109/PROC.1974.9449
• Richard Hartley and Andrew Zisserman (2003). Multiple View Geometry in computer vision. Cambridge University Press. ISBN 978-0-521-54051-3.