function translation()%读入图片
image =imread('Fig3.tif');%偏移量
delta_x =20;
delta_y =20;[n ,m]=size(image);
newImage =zeros(256,256);%开始偏移
for i =1: n
for j =1: m
pos =[i; j;1];
delta =[10 delta_x;01 delta_y;001];
pos = delta * pos;ifpos(1)<256&&pos(2)<256newImage(pos(1),pos(2))=image(i, j);
end
end
end
figure,imshow(uint8(newImage));
figure,imshow(image);
缩放
function zoom()%读入图片
image =imread('Fig3.tif');%缩放
a =2[n ,m]=size(image);
newImage =zeros(256,256);%开始偏移
for i =1: n
for j =1: m
pos =[i; j;1];
delta =[a 00;0 a 0;001];
pos = delta * pos;ifpos(1)<256&&pos(2)<256newImage(pos(1),pos(2))=image(i, j);newImage(pos(1),pos(2)+1)=image(i, j);newImage(pos(1)+1,pos(2))=image(i, j);newImage(pos(1)+1,pos(2)+1)=image(i, j);
end
end
end
figure,imshow(uint8(newImage));
figure,imshow(image);