title: proportions of a perspective-deformed rectangle
body: <p>Given a 2d picture of a rectangle distorted by perspective:</p>
  
  <p><img src="https://i.stack.imgur.com/rI36D.png" alt="enter image description here"></p>
  
  <p>I know that the shape was originally a rectangle, but I do not know its original size.</p>
  
  <p>If I know the pixel coordinates of the corners in this picture, how can I calculate the original proportions, i.e. the quotient ( width / height ) of the rectangle?</p>
  
  <p>(background: the goal is to automatically undistort photos of rectangular documents, edge detection will probably be done with hough transform)</p>
  
  <h1>UPDATE:</h1>
  
  <p>There has been some discussion on whether it is possible at all to determine the width:height ratio with the information given. My naive thought was that it must be possible, since I can think of no way to project for example a 1:4 rectangle onto the quadrangle depicted above. The ratio appears clearly close to 1:1, so there should be a way to determine it mathematically. I have however no proof for this beyond my intuitive guess.</p>
  
  <p>I have not yet fully understood the arguments presented below, but I think there must be some implicit assumption that we are missing here and that is interpreted differently.</p>
  
  <p>However, after hours of searching, I have finally found some papers relevant to the problem.
  I am struggling to understand the math used in there, so far without success. Particularly the first paper seems to discuss exactly what I wanted to do, unfortunately without code examples and very dense math.</p>
  
  <ul>
  <li><p>Zhengyou Zhang , Li-Wei He, "Whiteboard scanning and image enhancement"
  <a href="http://research.microsoft.com/en-us/um/people/zhang/papers/tr03-39.pdf" rel="noreferrer">http://research.microsoft.com/en-us/um/people/zhang/papers/tr03-39.pdf</a> p.11</p>
  
  <blockquote>
    <p>"Because of the perspective distortion, the image of a rectangle appears to be a quadrangle. However, since we know that it is a rectangle in space, we are able to estimate both the camera’s focal length and the rectangle’s aspect ratio."</p>
  </blockquote></li>
  <li><p>ROBERT M. HARALICK "Determining camera parameters from the perspective projection of a rectangle"
  <a href="http://portal.acm.org/citation.cfm?id=87146" rel="noreferrer">http://portal.acm.org/citation.cfm?id=87146</a></p>
  
  <blockquote>
    <p>"we show how to use the 2D perspective projection of a rectangle of unknown size and position in 3D space to determine the camera look angle parameters relative to the plans of the rectangle."</p>
  </blockquote></li>
  </ul>