TForm homography

Control Point Selection

close all
clear
filename = '2016-02-17_18-27-20.JPG';
rgb = imread(filename);

ref = imread('pat2s.jpg');

cpselect(rgb,ref);

Projective Transformation

save cpoints cpstruct fixedPoints movingPoints

tf = fitgeotrans(movingPoints,fixedPoints,'projective')

format shortg
disp('tf.T');
disp(tf.T)
format
fprintf('norm T: %g\n',norm(tf.T));
fprintf('det T: %g\n',det(tf.T));

Verify Transform

[x y] = transformPointsForward(tf,movingPoints(:,1),movingPoints(:,2));
[x y]
fixedPoints

Apply Transform manually

H = tf.T;
hpts = [movingPoints ones(4,1)];
hout = hpts*H;
format shortg
disp('hout');
disp(hout);
format
pts = hout(:,1:2)./(hout(:,3)*ones(1,2))
fixedPoints

Apply transform to image

[out ref] = imwarp(rgb,tf);
imshow(out);
ref

Adjust reference values

myref = imref2d([640 640],[-500 600],[-500 600]);
[out ref] = imwarp(rgb,tf,'OutputView',myref,'FillValues',[255 255 0]);
imshow(out);
ref