Take the 2-minute tour ×
Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. It's 100% free, no registration required.

I've detected a few lines in an image. Four of them are the edges of a square depicted in the image. The projective transformation of the camera has of course been applied to all the lines, making it impossible to use regular metrics such as straight angles and so on.

If I draw four randomly chosen lines from the attached image. Is there any way to decide whether those lines are the edges of a square?

Depicted lines

share|improve this question
add comment

2 Answers

Any set of four lines can represent the image of a square under a projective transform: Suppose your lines are $g_1$ through $g_4$. Let $P$ be the intersection of $g_1$ with $g_3$ and $Q$ be the intersection of $g_2$ with $g_4$. Then the line $\ell$ connecting $P$ and $Q$ will serve as the line at infinity. Any transformation which maps that line back to infinity will turn your quadrilateral into a parallelogram, a shear will turn that into a rectangle, and an anisotropic scale that into a square. All of the operations can be combined into a single projective transformation.

You might be able to rule out some combinatuons, where a line segment passes past a corner of the assumed suqare, but other than that, you simply have too little information.

share|improve this answer
add comment

In this answer and its referenced answer it is shown that any convex quadrilateral can represent a square under a perspective projection. If the quadrilateral is not convex, the edges are virtual projections from behind the plane of the viewer.

share|improve this answer
add comment

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.