title: MATLAB How to convert axis coordinates to pixel coordinates?
body: <p>What is the preferred way of converting from axis coordinates (e.g. those taken in by <code>plot</code> or those output in <code>point1</code> and <code>point2</code> of <code>houghlines</code>) to pixel coordinates in an image?</p>
  
  <p>I see the function <a href="http://www.mathworks.com/help/toolbox/images/ref/axes2pix.html" rel="nofollow noreferrer">axes2pix</a> in the Mathworks documentation, but it is unclear how it works. Specifically, what is the third argument? The examples just pass in <code>30</code>, but it is unclear where this value comes from. The explanations depend on a knowledge of several other functions, which I don't know.</p>
  
  <p>The related question: <a href="https://stackoverflow.com/q/7721255">Axis coordinates to pixel coordinates?</a> suggests using <code>poly2mask</code>, which would work for a polygon, but how do I do the same thing for a single point, or a list of points?</p>
  
  <p>That question also links to <a href="http://www.mathworks.com/matlabcentral/fileexchange/29598-convert-image-to-and-from-graph-coordinates" rel="nofollow noreferrer">Scripts to Convert Image to and from Graph Coordinates</a>, but that code threw an exception:</p>
  
  <pre><code>Error using  / 
  Matrix dimensions must agree.
  </code></pre>