1 简介
当今时代,科学技术发展迅猛,网络成为人们获取成为人们获取多媒体数字信息的主要渠道,数字图像作为日常交流的主要传输媒介,更是承担着信息传递的重任。保证信息在传播过程中的安全性和完整性便成了目前研究的重中之重,优化图像加密方法,设计出满足社会发展和日常生活需求的加密系统刻不容缓。传统的加密方法可有效地用于文本或二进制数据加密,但对于图像、视频和音频等数字媒体却不是理想的选择。数字媒体的特点是数据量巨大、相邻像素相关性强、特征冗余度高,且其对比特率和带宽要求高。混沌系统的初始参数敏感性、类随机性、不可预测性等特性完全符合图像加密系统设计要求。本文围绕基于Logistic混沌图像加密与解密算法的研究。
2 部分代码
function varargout = software(varargin)
% SOFTWARE M-file for software.fig
% SOFTWARE, by itself, creates a new SOFTWARE or raises the existing
% singleton*.
%
% H = SOFTWARE returns the handle to a new SOFTWARE or the handle to
% the existing singleton*.
%
% SOFTWARE('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in SOFTWARE.M with the given input arguments.
%
% SOFTWARE('Property','Value',...) creates a new SOFTWARE or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before software_OpeningFunction gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to software_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
% Copyright 2002-2003 The MathWorks, Inc.
% Edit the above text to modify the response to help software
% Last Modified by GUIDE v2.5 15-Jun-2021 12:02:41
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @software_OpeningFcn, ...
'gui_OutputFcn', @software_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 software is made visible.
function software_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 software (see VARARGIN)
% Choose default command line output for software
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
% UIWAIT makes software wait for user response (see UIRESUME)
% uiwait(handles.figure1);
% --- Outputs from this function are returned to the command line.
function varargout = software_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;
%列解密
for f=m1+1:m1+n1-1
for h=f:m1+n1
if y(f)>y(h)
m=y(f);
y(f)=y(h);
y(h)=m;
c1=a(:,f-m1,:);
a(:,f-m1,:)=a(:,h-m1,:);
a(:,h-m1,:)=c1;
end
end
waitbar(f/(m1+n1-1),hr,'等待正在解密...');
end
waitbar(1,hr,'完成!');
delete(hr);
pause(0.5);
%图像去噪修复
for f=2:n1
if a(1,f,:)<=0
a(1,f,:)=a(1,f-1,:);
end
end
for g=2:m1
if a(g,1,:)<=0
a(g,1,:)=a(g-1,1,:);
end
end
for g=2:m1
for f=2:n1
if a(g,f,:)<=0
a(g,f,:)=a(g-1,f,:)/2+a(g,f-1,:)/2;
end
end
end
b=a;
axes(handles.axes1);
imshow(real(b));
imwrite(b,'b.bmp');
% --- 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)
clear all;
close(gcf);
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
function edit3_Callback(hObject, eventdata, handles)
% hObject handle to edit3 (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 edit3 as text
% str2double(get(hObject,'String')) returns contents of edit3 as a double
% --- Executes during object creation, after setting all properties.
function edit3_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit3 (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
% --- 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)
global a;
%3D特效
A=a;
sizeA=size(A);
x=sizeA(1);
y=sizeA(2);
double z;
%nfine=3;
for i=1:x
for j=1:y
Z(i,j)=(30*double(A(i,j,1))+59*double(A(i,j,2))+11*double(A(i,j,3)))/10;
end
end
%X=1:(nfine-1):x;
%Y=1:(nfine-1):y;
[X,Y]=meshgrid(1:x,1:y);
h=mesh(Z');
axis off;
view(90,90);
for i=1:12
rotate(h,[1,0,0],30);
mmm(i)=getframe;
%pause(0.5);
%rotate(h,[1,0,0],10);
%mmm(i)=getframe;
end
movie(mmm,1,10);
3 仿真结果
4 参考文献
[1]崔莉. 基于混沌映射的数字图像隐藏和加密方法研究.
部分理论引用网络文献,若有侵权联系博主删除。
5 MATLAB代码与数据下载地址
见博客主页