ewoksndreg.transformation.lstsq.calc_projective#
- ewoksndreg.transformation.lstsq.calc_projective(from_coord, to_coord)[source]#
Coordinate array shape is (ndim, ncoord).
Find the projective transformation between two sets of coordinates by solving this system of equations:
\[\begin{align*} x' &= \frac{a.x + b.y + t_0}{p_x.x+p_y.y+1} y' &= \frac{c.x + d.y + t_1}{p_x.x+p_y.y+1} x' &= a.x + b.y + t_0 - p_x.x.x' - p_y.y.x' y' &= c.x + d.y + t_1 - p_x.x.y' - p_y.y.y' \mathrm{sol} &= [a, b, t_0, c, d, t_1 , p_x, p_y] \end{align*}\]\[\begin{split}\begin{equation*} \begin{bmatrix} x_1 & y1 & 1 & 0 & 0 & 0 & -x_1.x_1' & -y1.x_1' 0 & 0 & 0 & x_1 & y1 & 1 & -x_1.y1' & -y1.y1' x_2 & y_2 & 1 & 0 & 0 & 0 & -x_2.x_2' & -y_2.x_2' 0 & 0 & 0 & x_2 & y_2 & 1 & -x_2.y_2' & -y_2.y_2' \vdots \end{bmatrix}. \mathrm{sol} = \begin{bmatrix} x_1' \\ y1' \\ x_2' \\ y_2' \\ \vdots \end{bmatrix} \end{equation*}\end{split}\]The resulting transformation matrix is
\[\begin{split}\begin{equation*} \mathrm{sol}=\begin{bmatrix} a & b & t_0\\ c & d & t_1\\ p_x & p_y & 1 \end{bmatrix} \end{equation*}\end{split}\]- Parameters:
from_coord (
Sequence
[ndarray
])to_coord (
Sequence
[ndarray
])
- Return type:
ndarray