im=imread('~/Desktop/Teaching/Images/flower.tiff');
img=rgb2gray(imresize(im,.25));

figure(1);
subplot(1,2,1);
imagesc(img);
timg=zeros(size(img));

[sy,sx]=size(img);

theta=pi/4;
A=[cos(theta) sin(theta) 0; -sin(theta) cos(theta) 0; 0 0 1];


for oy=1:sy
  for ox=1:sx
     oxy=[ox; oy; 1];
     nxy=A*oxy;
     nx=round(nxy(1));
     ny=round(nxy(2));
     if (nx>0 && nx<=sx && ny>0 && ny<=sy)
       timg(ny,nx)=img(oy,ox);
     end
  end
end


subplot(1,2,2);
imagesc(timg);
    
