matrix transformation of deformed rectangle

684 Views Asked by At

I am working on touch screen calibration, and have come across a problem.

My area of touch screen input is a Trapezoid which looks like a square on one side and a triangle on the other.

enter image description here

(the angle is not even close to that bad, but it is the shape)

I need to transform this shape into a rectangle.

I can apply matrix multiplications, but I don't know if it is even possible to change its shape to a rectangle using linear transformations.

1

There are 1 best solutions below

0
On BEST ANSWER

Yes, there is a matrix that will transform the Trapezoid into a square. It is linear but not affine. I believe it would be a Perspective Transform.

The matrix is $$\begin{bmatrix} \frac{x}{x_1} & \frac{x}{y}(1-\frac{x_2}{x_1}) &0 \\0 & 1 & 0 \\0 & 0 & 1 \end{bmatrix}$$

Where $x_1$ is the length of the bottom of the trapezoid, $x_2$ is the length of the top, and $x$ is the length of the rectangle.