Code covered by the BSD License  

Highlights from
Image 2D Transformations

from Image 2D Transformations by Madhu S. Nair
Image 2D Transformations Translation Rotation Scaling

translate(x)
%Question No:15
%IMAGE TRANSLATION

function translate(x)
f=imread(x);
[r,c]=size(f);
tx=input('Enter the translation parameter tx = ');
ty=input('Enter the translation parameter ty = ');
for i=1:r-tx
    for j=1:c-ty
       T(i+tx,j+ty)=f(i,j);
    end
end
imshow(f), figure, imshow(T);

Contact us at files@mathworks.com