function chengxu()
A=imread('lena.png');
figure,imshow(A);
title('原图像(256*256)');
for K=1:16 %置乱16次
B=zhiluan(A); %调用zhuluan函数,实现置乱
figure,imshow(B);
title(['置乱',num2str(K),'次后的图像'])
A=B;
end
msgbox('MATLAB编程答疑,请加QQ: 1530497909','MATLAB答疑','help')
web http://url.cn/TKcdXk -browser
end
function B=zhiluan(A)
%此函数将图像A置乱,输出置乱后的图像B
[M,N]=size(A);
for x=1:N
for y=1:N
if x<y %计算(x,y)点映射到B图像的坐标(x1,y1)
x1=x-y+N+1;
y1=-x+N+1;
else
x1=x-y+1;
y1=-x+N+1;
end
B(x1,y1)=A(x,y); %B图像的像素幅值
end
end
end