Intereting Posts

Convexity definition confusion
Is my proof correct: rank-nullity in a field $K$
Elementary proof that $Gl_n(\mathbb R)$ and $Gl_m(R)$ are homeomorphic iff $n=m$
When is $\mathbb{Z}$ not an UFD (for $d>1$)?
What is the highest power of $n$ in $(n^r-1)!$
Explaining the product of two ideals
Positive series problem: $\sum\limits_{n\geq1}a_n=+\infty$ implies $\sum_{n\geq1}\frac{a_n}{1+a_n}=+\infty$
River flowing down a slope
A Question on Compact Operators
Translate an english sentence to first order logic
Closed Convex sets of $\mathbb{R^2}$
Partial Proof of Second Hardy-Littlewood Conjecture (modified)?
$G$ a finite group such that $x^2 = e$ for each $x$ implies $G \cong \mathbb{Z}_2 \times … \times \mathbb{Z}_2$ ($n$ factors)
What is the value of $\sum\limits_{i=1}^\infty\frac{1}{p_{p_i}}$ where $p_{i}$ is the $i$th prime?
RSA encryption. Breaking 2048 keys with index

I went through this thread

Mapping Irregular Quadrilateral to a Rectangle

If i know the 4 corresponding points in image say

p1->p1′

p2->p2′

p3->p3′

p4->p4′

then how to compute pi(x,y) from pi'(x,y)

- Elementary geometry from a higher perspective
- A diagram which is not the torus
- the 8 queens conjecture: the next level (or dimension)
- Three dimensional spherical excess formula
- how to find arc center when given two points and a radius
- Area of intersection between 4 circles centered at the vertices of a square

i don’t know how to compute elements in Homography matrix H from those 8 known points

[x’]= [h11 h12 h13] [x]

[y’]= [h21 h22 h23] [y]

[(1)]=[h31 h32 (1)] [(1)]

*[Excuse me. I am not sure if I should extend this question, or create a new one, since I can’t post comments on threads]*

I want to ask the same question, but using absolute values so I can visualize it.

Lets say my points on the image plane are:

```
p[0] = x:407 y:253
p[1] = x:386 y:253
p[2] = x:406 y:232
p[3] = x:385 y:232
```

these points are in a 500px width x 333px height image plane with 0,0 at top left corner. These points represents a picture of a real plane where a 30mm side square are located. Assuming this picture was taken by a fixed camera at origin heading Z axis.

So, I know the physical distance between p0,p1 ; p0,p2 ; p1,p3; p2,p3 are 30mm.

But is it possible to get the X,Y,Z from each of these points using only this information above?

- Proving linear independence
- geometry question on incenters
- Equilateral triangle whose vertices are lattice points?
- Show that if an ellipse and a hyperbola have the same foci, then at each point of intersection their tangent lines are perpendicular.
- Can the “inducing” vector norm be deduced or “recovered” from an induced norm?
- How to prove the midpoint of a chord is also the midpoint of the line segment defined by the points of intersection of other two chords with it?
- Matrix diagonalizable or not
- Finding $P$ such that $P^TAP$ is a diagonal matrix
- Matrix Group induction proof and order of elements question
- Compute center, axes and rotation from equation of ellipse

You can compute the homography matrix H with your eight points with a matrix system such that the four correspondance points $(p_1, p_1′), (p_2, p_2′), (p_3, p_3′), (p_4, p_4′)$ are written as $9\times2$ matrices such as:

$p_i = \begin{bmatrix}

-x_i \quad -y_i \quad -1 \quad 0 \quad 0 \quad 0 \quad x_ix_i’ \quad y_ix_i’ \quad x_i’ \\

0 \quad 0 \quad 0 \quad -x_i \quad -y_i \quad -1 \quad x_iy_i’ \quad y_iy_i’ \quad y_i’

\end{bmatrix}$

It is then possible to stack them into a matrix $P$ to compute:

$PH = 0$

Such as:

$PH = \begin{bmatrix}

-x_1 \quad -y_1 \quad -1 \quad 0 \quad 0 \quad 0 \quad x_1x_1′ \quad y_1x_1′ \quad x_1′ \\

0 \quad 0 \quad 0 \quad -x_1 \quad -y_1 \quad -1 \quad x_1y_1′ \quad y_1y_1′ \quad y_1′ \\

-x_2 \quad -y_2 \quad -1 \quad 0 \quad 0 \quad 0 \quad x_2x_2′ \quad y_2x_2′ \quad x_2′ \\

0 \quad 0 \quad 0 \quad -x_2 \quad -y_2 \quad -1 \quad x_2y_2′ \quad y_2y_2′ \quad y_2′ \\

-x_3 \quad -y_3 \quad -1 \quad 0 \quad 0 \quad 0 \quad x_3x_3′ \quad y_3x_3′ \quad x_3′ \\

0 \quad 0 \quad 0 \quad -x_3 \quad -y_3 \quad -1 \quad x_3y_3′ \quad y_3y_3′ \quad y_3′ \\

-x_4 \quad -y_4 \quad -1 \quad 0 \quad 0 \quad 0 \quad x_4x_4′ \quad y_4x_4′ \quad x_4′ \\

0 \quad 0 \quad 0 \quad -x_4 \quad -y_4 \quad -1 \quad x_4y_4′ \quad y_4y_4′ \quad y_4′ \\

\end{bmatrix} \begin{bmatrix}h1 \\ h2 \\ h3 \\ h4 \\ h5 \\ h6 \\ h7 \\ h8 \\h9 \end{bmatrix} = 0$

While adding an extra constraint $|H|=1$ to avoid the obvious solution of $H$ being all zeros. It is easy to use SVD $P = USV^\top$ and select the last singular vector of $V$ as the solution to $H$.

Note that this gives you a DLT (direct linear transform) homograhpy that minimizes algebraic error. This error is not geometrically meaningful and so the computed homography may not be as good as you expect. One typically applies nonlinear least squares with a better cost function (e.g. symmetric transfer error) to improve the homography.

Once you have your homography matrix $H$, you can compute the projected coordinates of any point $p(x, y)$ such as:

$\begin{bmatrix}

x’ / \lambda \\

y’ / \lambda \\

\lambda

\end{bmatrix} =

\begin{bmatrix}

h_{11} & h_{12} & h_{13} \\

h_{21} & h_{22} & h_{23} \\

h_{31} & h_{32} & h_{33}

\end{bmatrix}.

\begin{bmatrix}

x \\

y \\

1

\end{bmatrix}$

After a while I am answering my own question (in a way I can understand.I hope it can help other people too)

I am really sorry for not having a good math basis, but there is a GAP between information most people provide from copy/pasted formulas found on google and what I can understand. I see, by the way, many formulas have some mistakes that confuses those in the search of an answer.

So,

Basically, you have 2 collections of 4 points, A and B rectangles.

```
A = { p1x,p1y ; p2x,p2y ; p3x,p3y ; p4x,p4y }
B = { p1x,p1y ; p2x,p2y ; p3x,p3y ; p4x,p4y }
```

I want to map a point in rectangle A to rectangle B.

I then build a 8 x **n** matrix (M1), where **n** is number of points * 2(x,y). (result will be a 8×8 matrix)

```
for each point:
{xA, yA, 1, 0, 0, 0, -xA*xB, -yA*xB}
{0, 0, 0, xA, yA, 1, -xA*yB, -yA*yB}
```

I also make a 1 x 8 matrix (M2) with the “target”(B) points. Result must be 1×8 and not 8×1.

```
for each point:
{xB}
{yB}
```

Next, we are finding the so called H matrix.

I am using this formula:

```
H = ( M1 transpose * M1 )inv * ( M1 transpose * M2)
```

Result is a 3 x 3 matrix (H).

Finally, any 2d point in rectangle A can be found in rectangle B using this operation:

```
point_in_A = (x,y,1)
tempMatrix (1x3) = H(3x3) * point_in_A(1x3)
tempMatrix will be (x, y, scale);
```

using tempMatrix values below:

```
result xy_in_B = (x / scale , y / scale);
```

That is it.

- Simplifying my sum which contains binomials
- Closed form for $\sum_{n=1}^\infty\frac{(-1)^n n^a H_n}{2^n}$
- How to use Fermat's little theorem to find $50^{50}\pmod{13}$?
- Show that $\sum_{j=m-1}^{n-1}(-1)^{j-m+1}\binom{j}{m-1}\binom{n}{j+1}=1$ for $n\ge m$
- Numerical computation of the Rayleigh-Lamb curves
- Cesaro summable implies Abel summable
- Integrating around a dog bone contour
- The set of all nilpotent elements is an ideal
- Exponential map is surjective for compact connected Lie group
- Christoffel Symbols as Tensors
- Kummer's test – Calculus, Apostol, 10.16 #15.
- How is the concept of the limit the foundation of calculus?
- Prove $R \times R$ is NOT an integral domain
- How to visualize $1$-forms and $p$-forms?
- What is the expected value of the number of die rolls necessary to get a specific number?