以灰度图像cameraman.tif为例,通过Matlab编程实现水平镜像和垂直镜像变换
I=imread('cameraman.tif');
[M,N]=size(I);
I_shuiping=I;
for i=1:M
for j=1:N
I_shuiping(i,j)=I(i,N-j+1);
end
end
subplot(2,2,1);
imshow(I);
subplot(2,2,2);
imshow(I_shuiping);
I_chuizhi=I;
for i=1:M
for j=1:N
I_chuizhi(i,j)=I(M-i+1,j);
end
end
subplot(2,2,3);
imshow(I_chuizhi);