function el 
%应用混沌序列与原始图像的异或对原始图像进行加密
clear;
clc;
%需要注意本程序实现对二进制文件的加密,对于非二进制文件不能采用此程序进行加密!!!!
[filename pathname]=uigetfile('*.bmp;*.tiff;*.tif', '读入图像');
os=[pathname filename];
%os原始图像的路径
o=imread(os);
% figure,imshow(o);
%计算原始图像的大小
[m n]=size(o);
l=zeros(m,n);
l(1)=0.98;
for i=2:m*n
l(i)=1-2*l(i-1)*l(i-1);
end
% %对生成的混沌序列进行排序
% [lsort lindex]=sort(l);
% t=linspace(0,0,m*n);
% t(1)=0.98;
% for i=1:m*n
% t(i+1)=1-2*t(i)*t(i);
% end
for i=1:m*n
if (l(i)>=0)
l(i)=1;
else
l(i)=0;
end
end
% l=~l;
ei=xor(o,l);
di=xor(ei,l);
h= waitbar(0,'程序处理中,请耐心等待。。。');
for i=1:100, % computation here %
waitbar(i/100)
end
close(h)
subplot(2,2,1),imshow(o),title('原始图像');
subplot(2,2,2),imshow(l),title('混沌图像');
% figure,imshow(l);
%ei表示加密图像encryption image
subplot(2,2,3),imshow(ei),title('加密图像');
%di表示解密图像dencryption image
subplot(2,2,4),imshow(di,[]),title('解密图像');
% figure,imshow(di);

 

 

应用混沌系统进行异或加密_image

 

​​