混沌 Cat 映射
function newx=Catmap(x)
% Cat映射
% x(n+1)=x(n)+y(n) (mod 1)
% y(n+1)=x(n)+2*y(n) (mod 1)
%
%
newx(1)=mod(x(1)+x(2),1);
newx(2)=mod(x(1)+2*x(2),1);
function test
clear all
% 读曲图象(路径按自己情况改)
f=imread('cat.jpg');
A=double(f)/255;
[m,n,l]=size(A);
subplot(3,2,1)
imagesc(A,[0 1]);
for k=1:5
S=zeros(m,n);
for i=1:m
for j=1:n
c=[(i-1)/m (j-1)/n];
c=Catmap(c);
ib=fix(m*c(1))+1;
jb=fix(n*c(2))+1;
if S(ib,jb)==0
B(ib,jb,:)=A(i,j,:);
S(ib,jb)=1;
% 如有变换后的点重叠,移到邻近单元,减少信息损失
elseif jb<n & S(ib,jb+1)==0
B(ib,jb+1,:)=A(i,j,:);
S(ib,jb+1)=1;
elseif ib<m & S(ib+1,jb)==0
B(ib+1,jb,:)=A(i,j,:);
S(ib+1,jb)=1;
end
end
end
subplot(3,2,k+1)
imagesc(B,[0 1]);
A=B;
end
变换的原图
No comments:
Post a Comment