%This script demonstrates how to perform geometric transformations to a given image
%and show the two images in the same coordinate system.
%by Lin ZHANG, SSE, Tongji University, Mar. 2013
     clc
     close all
     clear all
im = imread('tongji.bmp');

theta = pi/4;
affineMatrix = [cos(theta) sin(theta) 0;-sin(theta) cos(theta) 0;-300 0 1];

tformAffine = maketform('affine',affineMatrix);

[affineIm, XData, YData] = imtransform(im, tformAffine,'FillValues',255);
figure;
imshow(im,[]);
hold on
imshow(affineIm,[],'XData',XData,'YData',YData);
axis auto
axis on