求助用matlab实现图像加密 基于lorenz混沌映射的

求助用matlab实现图像加密 基于lorenz混沌映射的,第1张

使带棚和用以下代码:蠢盯 clearclcx=imread('lena.bmp','和戚bmp')[a b c]=size(x)N=a*bm(1)=input('请输入密钥: ')disp('加密中...')for i=1:N-1 m(i+1)=4*m(i)-4*m(i)^2end

基于Arnold变换的图像7a686964616fe4b893e5b19e31333264636332加密: 记住把注释掉的程序单独写个M文件,放在同一路径下

clcclearclose all

randoma=input('请输入用户指令:','s')%

P=randoma

%P=str2num(P)

if (P=='*****')

tu=uigetfile()

I=imread(tu)

imshow(tu)hold on

%imshow('tu')

[M,N,P]=size(I)

rand('state',0)

% randoma=input('请输入用户指令:正键')%

% P=randoma

% if (P==3.14)

T=96

R=rand(M,N)*pi*2

xlswrite('R.xls',R)

%kk=xlsread('jjm.xls')%32 43 55 63

a1=input('请输入a1:')

a2=input('请输入a2:')

a3=input('请输入a3:')

a4=input('请输入a4:')

kk=[a1,a2,a3,a4]

xlswrite('kk.xls',kk)

%%

I=double(I)

Ie=encrypt(I,R,kk)

figure

imshow(Ie,[])

%%

%%加密图像 其中调用了encrypt函数

%function Ie=encrypt(I,R,kk)

%Ir=I(:,:,1)Ig=I(:,:,2)Ib=I(:,:,3)

% [Xr,Xg,Xb]=Tmatrix(Ir,Ig,Ib,R)

% I1r=blkart2a(Xr,kk)I1g=blkart2a(Xg,kk)I1b=blkart2a(Xb,kk)

% I0r=dct2(I1r)I0g=dct2(I1g)I0b=dct2(I1b)

% [X1r,X1g,X1b]=Tmatrix(I0r,I0g,I0b,R)

% I2r=blkart2a(X1r,kk)I2g=blkart2a(X1g,kk)I2b=blkart2a(X1b,kk)

% I3r=idct2(I2r)I3g=idct2(I2g)I3b=idct2(I2b)

% Ie(:,:,1)=I3rIe(:,:,2)=I3gIe(:,:,3)=I3b

% [Xr,Xg,Xb]=Tmatrix(Ir,Ig,Ib,R)

% Xr=Ir.*cos(R)+Ig.*sin(R).^2-Ib.*sin(R).*cos(R)

% Xg=-Ir.*sin(R)+Ig.*sin(R).*cos(R)-Ib.*cos(R).^2

% Xb=Ig.*cos(R)+Ib.*sin(R)

a1=input('请输入a1:')

a2=input('请输入a2:')

a3=input('请输入a3:')

a4=input('请输入a4:')

kk=[a1,a2,a3,a4]

R=uigetfile()

R=xlsread('R.xls')

%%

Ii=decrypt(Ie,R,kk)

Ii=Ii-min(Ii(:))Ii=Ii/max(Ii(:))

h = waitbar(0,'Please wait...')

steps = 600

for step = 1:steps

%figureimshow(Ii,[])

waitbar(step / steps)

end

close(h)

figureimshow(Ii,[])

h = waitbar(1,'完察运成败清梁解密','color','')

steps = 1

for step = 1:steps

h = waitbar(1,'finish!','color','')

end

close(h)

warning off

end

%%

%%解密图像,调用decrypt函数

% function J=decrypt(Ie,R,kk)

% T=96% period of Arnold transform

% J2r=Ie(:,:,1)J2g=Ie(:,:,2)J2b=Ie(:,:,3)

% J2r=dct2(J2r)J2g=dct2(J2g)J2b=dct2(J2b)

% Y1r=blkart2a(J2r,T-kk)Y1g=blkart2a(J2g,T-kk)Y1b=blkart2a(J2b,T-kk)

% [J0r,J0g,J0b]=iTmatrix(Y1r,Y1g,Y1b,R)

% J1r=idct2(J0r)J1g=idct2(J0g)J1b=idct2(J0b)

% Yr=blkart2a(J1r,T-kk)Yg=blkart2a(J1g,T-kk)Yb=blkart2a(J1b,T-kk)

% [Jr,Jg,Jb]=iTmatrix(Yr,Yg,Yb,R)

% J(:,:,1)=JrJ(:,:,2)=JgJ(:,:,3)=Jb

% x(n+1)=1-ux(n)^2 %混沌的迭代表猜腊达式

% u in (0,2]

% x in (-1,1)

clear all

u=linspace(0,2,200) %u在0到2之间均匀取200个点

for k=1:200 %循环控制,迭代200次

x0=0.42212 %对x0赋初值

for p=1:200%嵌套循环200次

xn=1-u(k)*x0*x0 %迭代控制语句

if p<100 %迭代羡迅100次以前为0

plot(0,0)

else

hold on

plot(u(k),xn,'.','Markersize',2)%当迭代大于100次时,每迭代一穗派滑次,在图上将迭代的x值画出

end

x0=xn %迭代结果为下一次迭代赋初值

end

end


欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/yw/8235691.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-04-14
下一篇 2023-04-14

发表评论

登录后才能评论

评论列表(0条)

保存