% using the n-point homography estimation functions: % cp = [ 0 0 ; 0 1 ; 1 0 ; 1 1 ]; % any number of points > 3 is OK lp = [ 10 10 ; 10 11 ; 11 10 ; 11 11 ]; % these correspond to cp % the following lines % first append a third coordinate of 1 to each point % then take the transpose % to put the data into the format that homography2d requires cpReformatted = [ cp, ones(4, 1) ]'; lpReformatted = [ lp, ones(4, 1) ]'; % this returns the 3x3 homography, H H = homography2d( cpReformatted, lpReformatted ); % this creates a Matlab transform structure named tform % Here, we need to use the transpose of H in order to % meet the expectations of Matlab's maketform function tform = maketform( 'projective', H' ); % Here is the output from the above run: >> H H = 0.5774 -0.0000 5.7735 -0.0000 0.5774 5.7735 -0.0000 -0.0000 0.5774 >> H / H(2,2) ans = 1.0000 -0.0000 10.0000 -0.0000 1.0000 10.0000 -0.0000 -0.0000 1.0000