title: Swap frames on Matlab
body: <p>I need to write a MATLAB script which takes a photo, mark 4 points (which make a 4-pointed shape, for example with <code>ginput</code>), and puts another image into that frame. This process might require all standard transformations: (shear, translate, scale or rotate), as the frame is not necessarily a rectangle (most probably a rectangle being shot from some angle).</p>
  
  <p>I need help in finding and implementing the geometric transformation for the image to the frame.</p>
  
  <p>Any suggestions? Thanks ahead</p>
  
  <p>edit: to be more specific, I'm not sure how to calculate the transformation matrix after finding the relevant 4 points (x,y) coordinate matrix, which I find by using a function I created</p>
  
  <pre><code>function [framePoints] = manualMarkPoints(Image)
  figure(2)
  imshow(Image, [])
  title('pick 4 points for the frame, then press ENTER')
  
  [x, y] = ginput;
  framePoints = [x y];
  </code></pre>