【logistic-map混沌】一种基于logistic-map的混合混沌序列的图像加解密算法仿真

1.软件版本

MATLAB2013b

2.本算法理论知识

针对这个要求,我进一步做了部分改进,改进思路如下:

这里,考虑一种logistic-map的混合混沌序列替代传统的logistic序列。

logistic序列

程序对应的是:

logistic-map改进公式进行设计,如下:

我根据这种改进公式进行设计,代码如下:

3.部分核心代码

function varargout = topss(varargin)
% TOPSS MATLAB code for topss.fig
%      TOPSS, by itself, creates a new TOPSS or raises the existing
%      singleton*.
%
%      H = TOPSS returns the handle to a new TOPSS or the handle to
%      the existing singleton*.
%
%      TOPSS('CALLBACK',hObject,eventData,handles,...) calls the local
%      function named CALLBACK in TOPSS.M with the given input arguments.
%
%      TOPSS('Property','Value',...) creates a new TOPSS or raises the
%      existing singleton*.  Starting from the left, property value pairs are
%      applied to the GUI before topss_OpeningFcn gets called.  An
%      unrecognized property name or invalid value makes property application
%      stop.  All inputs are passed to topss_OpeningFcn via varargin.
%
%      *See GUI Options on GUIDE's Tools menu.  Choose "GUI allows only one
%      instance to run (singleton)".
%
% See also: GUIDE, GUIDATA, GUIHANDLES

% Edit the above text to modify the response to help topss

% Last Modified by GUIDE v2.5 19-Apr-2019 18:31:39

% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name',       mfilename, ...
                   'gui_Singleton',  gui_Singleton, ...
                   'gui_OpeningFcn', @topss_OpeningFcn, ...
                   'gui_OutputFcn',  @topss_OutputFcn, ...
                   'gui_LayoutFcn',  [] , ...
                   'gui_Callback',   []);
if nargin && ischar(varargin{1})
    gui_State.gui_Callback = str2func(varargin{1});
end

if nargout
    [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
else
    gui_mainfcn(gui_State, varargin{:});
end
% End initialization code - DO NOT EDIT


% --- Executes just before topss is made visible.
function topss_OpeningFcn(hObject, eventdata, handles, varargin)
% This function has no output args, see OutputFcn.
% hObject    handle to figure
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
% varargin   command line arguments to topss (see VARARGIN)

% Choose default command line output for topss
handles.output = hObject;

% Update handles structure
guidata(hObject, handles);

% UIWAIT makes topss wait for user response (see UIRESUME)
% uiwait(handles.figure1);


% --- Outputs from this function are returned to the command line.
function varargout = topss_OutputFcn(hObject, eventdata, handles) 
% varargout  cell array for returning output args (see VARARGOUT);
% hObject    handle to figure
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Get default command line output from handles structure
varargout{1} = handles.output;


% --- Executes on button press in pushbutton1.
function pushbutton1_Callback(hObject, eventdata, handles)
% hObject    handle to pushbutton1 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
global types;
global Ijpg;
global Iwav;
global Itxt;
global signals1;
global y1;
global y2;
global Iter;
global Lens;
global Len;
global RR;
global vmin;
[filename,pathname]=uigetfile({'*.*';'*.jpg';'*.m';'*.wav'},'选择文件类型');
if isequal(filename,0)||isequal(pathname,0)
   errordlg('您还没有选取图片!!','温馨提示');%如果没有输入,则创建错误对话框
   return;
else
   file=[pathname,filename];%合成路径+文件名
   type=file(end-2:end);
   if type=='jpg'
      types=1; 
   end
   if type=='wav'
      types=2; 
   end
   if type(end)=='m'
      types=3;  
   end
end

if types==1
   Ijpg      = imread(file); 
   Ijpg      = imresize(Ijpg,0.5, 'bicubic');
   axes(handles.axes1);
   imshow(Ijpg)
   
   [R,C,K] = size(Ijpg);
   if K == 1
      signals2 = Ijpg; 
   else
      signals2 = rgb2gray(Ijpg); 
   end
%    figure;
%    imhist(signals2)
end
if types==2
   [Iwav,Fs] = audioread(file);  
   axes(handles.axes1);
   plot(Iwav)
end
if types==3
   run(file)
   data;  
   %将文本转换为数字
   Itxt= letter2num(data);
   axes(handles.axes1);
   plot(Itxt)
end

 

% --- Executes on button press in pushbutton2.
function pushbutton2_Callback(hObject, eventdata, handles)
% hObject    handle to pushbutton2 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)


paras;

if types==1
   [R,C,K] = size(Ijpg);
   if K == 1
      signals = Ijpg; 
   else
      signals = [Ijpg(:,:,1),Ijpg(:,:,2),Ijpg(:,:,3)]; 
   end
end

if types==2
    signals = Iwav;
    vmin     = min(signals);
    signals  = uint8(round(250*(signals-vmin)));
    RR       = 400;
    Len      = length(signals)-RR*floor(length(signals)/RR);
    signals2 = [signals;zeros(RR-Len,1)];
    Lens     = length(signals2);
    signals3 = reshape(signals2,[RR,floor(length(signals2)/RR)]);
    signals=signals3;
end

if types==3
    signals = Itxt';
    vmin     = min(signals);
    signals  = uint8(round(signals-vmin));
    RR       = 400;
    Len      = length(signals)-RR*floor(length(signals)/RR);
    signals2 = [signals;zeros(RR-Len,1)];
    Lens     = length(signals2);
    signals3 = reshape(signals2,[RR,floor(length(signals2)/RR)]);
    signals=signals3;
end



[M,N]=size(signals);



%logistic u值
r1   = 1.8;
r2   = 1.8;
tic;
%多次迭代,每次迭代初始值改变
Iter = str2num(get(handles.edit1, 'string'));

 



for i = 1:Iter
    %logistic初值
    if i == 1
       x1(1)= 0.6;
       x2(1)= 0.7;
    else
       x1(1)= x0;
       x2(1)= y0;
    end
    %通过baker映射对logistic混沌映射初值进行扰动
    [x0,y0] = func_baker(x1(1),x2(1));
    if i==1
       [signals1{i},y1{i},y2{i}] = func_jiami(signals,r1,r2,x0,y0,M,N);
    else
       [signals1{i},y1{i},y2{i}] = func_jiami(signals1{i-1},r1,r2,x0,y0,M,N);     
    end
end


result=imgentropy(signals1{Iter});
%信息熵
disp('信息熵');
result

toc
axes(handles.axes2);
  

if types==1
   if K==1 
      imshow(signals1{Iter}); 
   else
      tmps = signals1{Iter};
      tmps2(:,:,1) = tmps(:,1:C);
      tmps2(:,:,2) = tmps(:,C+1:2*C);
      tmps2(:,:,3) = tmps(:,2*C+1:3*C);
      imshow(tmps2);  
   end
   
   [R,C,K] = size(Ijpg);
   if K == 1
      signals2 = tmps2; 
   else
      signals2 = rgb2gray(tmps2); 
   end
%    figure;
%    imhist(signals2)
   
end
if types==2
   xx=reshape(signals1{Iter},[1,Lens]); 
   plot(xx)
end
if types==3
   xx=reshape(signals1{Iter},[1,Lens]); 
   plot(xx)
end


% --- Executes on button press in pushbutton3.
function pushbutton3_Callback(hObject, eventdata, handles)
% hObject    handle to pushbutton3 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
paras;
Pow = str2num(get(handles.edit2, 'string'));
Rs = signals1{Iter};
Rs = uint8(double(Rs)+Pow/100*randn(size(Rs)));

axes(handles.axes3);
  
if types==1
   if K==1 
      imshow(Rs);; 
   else
      tmps = Rs;
      tmps2(:,:,1) = tmps(:,1:C);
      tmps2(:,:,2) = tmps(:,C+1:2*C);
      tmps2(:,:,3) = tmps(:,2*C+1:3*C);
      imshow(tmps2);  
   end
   [R,C,K] = size(Ijpg);
   if K == 1
      signals2 = tmps2; 
   else
      signals2 = rgb2gray(tmps2); 
   end
%    figure;
%    imhist(signals2)
   
end
if types==2
   xx=reshape(Rs,[1,Lens]); 
   plot(xx)
end
if types==3
   xx=reshape(Rs,[1,Lens]); 
   plot(xx)
end


% --- Executes on button press in pushbutton4.
function pushbutton4_Callback(hObject, eventdata, handles)
% hObject    handle to pushbutton4 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
paras;

for i = 1:Iter
    if i == 1
       signals2 = func_jiemi(Rs,y1{Iter-i+1},y2{Iter-i+1},M,N);
    else
       signals2 = func_jiemi(signals2,y1{Iter-i+1},y2{Iter-i+1},M,N);  
    end
end 

axes(handles.axes4);
if types==1
   if K==1
      data = signals2;
   else
      data(:,:,1) = signals2(:,1:C);
      data(:,:,2) = signals2(:,C+1:2*C);
      data(:,:,3) = signals2(:,2*C+1:3*C);
   end
  imshow(data);   
   [R,C,K] = size(Ijpg);
   if K == 1
      signals3 = data; 
   else
      signals3 = rgb2gray(data); 
   end
%    figure;
%    imhist(signals3)
end
if types==2
    signals2b=reshape(signals2,[1,Lens]);
    signals2b=double(signals2b)/250+vmin;
    plot(signals2b(1:end-(RR-Len)));
end
if types==3
signals2b=reshape(signals2,[1,Lens]);
signals2b=double(signals2b);
plot(signals2b(1:end-(RR-Len)));
%输出文字
disp('解密文字');
signals2b(1:end-(RR-Len))+32
str=num2letter(signals2b(1:end-(RR-Len))+32)
str 
end


% --- Executes on button press in pushbutton5.
function pushbutton5_Callback(hObject, eventdata, handles)
% hObject    handle to pushbutton5 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
clc;
clear;
close all;



function edit1_Callback(hObject, eventdata, handles)
% hObject    handle to edit1 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of edit1 as text
%        str2double(get(hObject,'String')) returns contents of edit1 as a double


% --- Executes during object creation, after setting all properties.
function edit1_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit1 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end



function edit2_Callback(hObject, eventdata, handles)
% hObject    handle to edit2 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of edit2 as text
%        str2double(get(hObject,'String')) returns contents of edit2 as a double


% --- Executes during object creation, after setting all properties.
function edit2_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit2 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end

4.操作步骤与仿真结论

 参考文献A29-04:

 

  • 3
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

fpga和matlab

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值