【图像隐藏】基于DCT、DWT、LHA、LSB的数字图像信息隐藏系统含各类攻击和性能参数附matlab代码

 1 内容介绍

1.1 课题研究的目的和意义 自二十世纪九十年代以来,网络在我们的生活中得到了快速的普及,网络几乎存 在于家家户户中,特别是一些用于交流的软件自诞生以来更是为我们的生活都带来了 极大的便利,让人们的交流变得十分容易。但是网络在便利我们生活的同时,也给网络 安全造成了很大的威胁。比如我们通常利用网络或者多媒体去通信交流或者发送资料, 这种传递方式打破了以往的书信往来,大大便利了人民的生活,但是在这个消息传递过 程中网络上存在的处处可见的安全隐患却不容得我们小觑。比如非法者会通过截获秘 密信息,并对秘密信息进行一定的纂改后发出去,接收者就会接收到错误的信息从而 导致很大的失误,严重的话会对一个企业以及政府机关等等造成毁灭性打击。 为了打击这种利用网络窃密,甚至利用网络盗取国家机密或者企业机密去犯罪的 行为,除了通过公安机构报警处理这种事后处理方法,还应该考虑将这种行为直接在 源头处进行扼杀,所以研究信息安全技术刻不容缓。目前主要的信息安全技术有两种, 一种是传统的信息安全手段加密技术,另一种是新兴的信息安全手段信息隐藏技术[1]。 如今这两种技术均被人们广泛地研究与应用。加密技术的诞生比信息隐藏技术早了很 久,也是最传统的信息安全手段,加密技术是通过将明文进行一系列变换,得到一种完 全看不出明文原始样子的密文,通过将加密后的密文,传送到接收者的手中,接收者再 进行一系列的解密工作来保证信息安全[2]。加密技术的诞生给信息安全领域带来了很大 的突破,但是这种技术也带来一些问题,比如非法者可以完全看到这种加密信息,就会 有目的性地对加密信息进行突破,如果引起非法者的兴趣就会有很大可能被解密或者 被破坏。信息隐藏技术解决了加密技术这个容易被针对的问题,它隐藏了秘密信息的 存在性,使得非法者根本注意不到秘密信息的存在,就不会有针对性地进行攻击。这项 技术通过将秘密信息嵌入在可以公开传播的载体中,但并不改变该公开载体原本的样 子、价值等等,来实现秘密信息的传递[3]。但是,通过隐藏传递的秘密信息一旦被发现, 秘密信息将直接暴露,所以结合用户们对信息安全的这种高隐蔽和高安全的要求,考 虑到要将加密和信息隐藏结合起来[4]。

信息隐藏是一种新兴的信息安全技术,在信息战,数字媒体的知识产权保护和票据防伪等方面有许多重要的应用.但作为一门信息安全领域的学科,对它的安全性一直没有系统的理论研究.我们结合信息隐藏算法的相关知识,对基于图像的空域LSB隐藏算法、DWT变换算法、LHA算法和DCT变换域算法的安全性进行了分析,希望能对安全性的理论研究有所帮助.实验表明,该算法对椒盐、白噪声、滤波、剪切、压缩和旋转等一系列攻击都有较好的稳健性。

2 仿真代码

function varargout = info_hiding_gui(varargin)
% INFO_HIDING_GUI M-file for info_hiding_gui.fig
%      INFO_HIDING_GUI, by itself, creates a new INFO_HIDING_GUI or raises the existing
%      singleton*.
%
%      H = INFO_HIDING_GUI returns the handle to a new INFO_HIDING_GUI or the handle to
%      the existing singleton*.
%
%      INFO_HIDING_GUI('CALLBACK',hObject,eventData,handles,...) calls the local
%      function named CALLBACK in INFO_HIDING_GUI.M with the given input arguments.
%
%      INFO_HIDING_GUI('Property','Value',...) creates a new INFO_HIDING_GUI or raises the
%      existing singleton*.  Starting from the left, property value pairs are
%      applied to the GUI before info_hiding_gui_OpeningFcn gets called.  An
%      unrecognized property name or invalid value makes property application
%      stop.  All inputs are passed to info_hiding_gui_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 info_hiding_gui

% Last Modified by GUIDE v2.5 05-Jun-2010 19:09:16

% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name',       mfilename, ...
                   'gui_Singleton',  gui_Singleton, ...
                   'gui_OpeningFcn', @info_hiding_gui_OpeningFcn, ...
                   'gui_OutputFcn',  @info_hiding_gui_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 info_hiding_gui is made visible.
function info_hiding_gui_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 info_hiding_gui (see VARARGIN)
clc;
V=get(0,'screensize') ;%获取当前根屏幕的大小信息
a=V(3)/2-500;
b=V(4)/2-334;
set(gcf,'Position',[a b 1001 669])
%clear;
% Choose default command line output for info_hiding_gui
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
set(handles.radiobutton31,'value',1);%设置噪声攻击的默认值为“无噪声”
set(handles.radiobutton32,'value',1);%设置滤波处理的默认值为“无滤波”
set(handles.slider6,'value',0);%设置滑动条的默认值为0
set(handles.slider7,'value',0);
set(handles.slider8,'value',0);
%set(handles.slider9,'value',0);
set(handles.slider10,'value',0);
set(handles.edit8,'string',0);
set(handles.edit9,'string',0);
set(handles.edit10,'string',0);
%set(handles.edit11,'string',0);
set(handles.edit12,'string',0);
set(handles.edit15,'string',0);
%key_1=[];%初始化密钥为空
%key_2=[];
%set(handles.edit1,'string','');
%set(handles.edit2,'string','');

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


% --- Outputs from this function are returned to the command line.
function varargout = info_hiding_gui_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;

%X=imread('Lena.bmp');

X=im_message;
%计算原始图像直方图数据
%L=2;         %灰度级
nk0=0;
nk1=0;
[row,col]=size(X);
for i=1:row
    for j=1:col
        if X(i,j)==0
            nk0=nk0+1;
        else 
            nk1=nk1+1;
        end        
    end
end
%判断文件的存在
if exist('info_recover_image.bmp','file')==0
    errordlg('处理失败!');
    error();
end
Y=imread('info_recover_image.bmp');
[row_1,col_1]=size(Y);
%%判断两图像规格是否一样%%%
if row_1~=row||col_1~=col
    errordlg('处理失败!');
    error();
end

nj0=0;nj1=0;
[row,col]=size(Y);

for i=1:row
    for j=1:col
        if Y(i,j)==0
            nj0=nj0+1;
        else
            nj1=nj1+1;
        end   
    end
end
%计算原始图像和密写后图像的差异
Z=zeros(row,col);
for i=1:row
    for j=1:col
        if X(i,j)==Y(i,j)
            Z(i,j)=1;
        end
    end
end
%画图
figure
x=[0 1];
hist_comp=[nk0 nj0 ; nk1 nj1];
bar(x,hist_comp);
title('原始图像和密写图像直方图对比');
legend('原始图像直方图','密写图像直方图','Location','NorthWest');
figure
imshow(Z);
title('原始图像和密写图像差异对比');
 

% --- Executes on button press in pushbutton12.
function pushbutton12_Callback(hObject, eventdata, handles)
% hObject    handle to pushbutton12 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
response=questdlg('确定要关闭此程序?','提示对话框','关闭','取消',1);
if strcmp('关闭',response)
    close(gcf)
end

% --- Executes on button press in pushbutton13.
function pushbutton13_Callback(hObject, eventdata, handles)
% hObject    handle to pushbutton13 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
%msgbox('name','版权声明','string','Copyright ? 2010-2100 何杰 南京邮电大学' )
V=get(0,'screensize') ;%获取当前根屏幕的大小信息
a=V(3)/2-234+3;
b=V(4)/2-132+70;
copyright('Position',[a b 468 264])%设置弹出的copyright窗口在屏幕的中间附近位置
                                   

% --- Executes on button press in pushbutton14.
function pushbutton14_Callback(hObject, eventdata, handles)
% hObject    handle to pushbutton14 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
V=get(0,'screensize') ;%获取当前根屏幕的大小信息
a=V(3)/2-151;
b=V(4)/2-200+70;
thanks('Position',[a b 303 403])

% --- Executes on slider movement.
function slider6_Callback(hObject, eventdata, handles)
% hObject    handle to slider6 (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,'Value') returns position of slider
%        get(hObject,'Min') and get(hObject,'Max') to determine range of slider
gaussian_slide=get(handles.slider6,'value');
%disp(gaussian_slide)  %测试
set(handles.edit8,'string',gaussian_slide);

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

% Hint: slider controls usually have a light gray background.
if isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor',[.9 .9 .9]);
end


% --- Executes on slider movement.
function slider7_Callback(hObject, eventdata, handles)
% hObject    handle to slider7 (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,'Value') returns position of slider
%        get(hObject,'Min') and get(hObject,'Max') to determine range of slider
salt_slide=get(handles.slider7,'value');
%disp(gaussian_slide)  %测试
set(handles.edit9,'string',salt_slide);

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

% Hint: slider controls usually have a light gray background.
if isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor',[.9 .9 .9]);
end


% --- Executes on slider movement.
function slider8_Callback(hObject, eventdata, handles)
% hObject    handle to slider8 (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,'Value') returns position of slider
%        get(hObject,'Min') and get(hObject,'Max') to determine range of slider
localvar_slide=get(handles.slider8,'value');
%disp(gaussian_slide)  %测试
set(handles.edit10,'string',localvar_slide);

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

% Hint: slider controls usually have a light gray background.
if isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor',[.9 .9 .9]);
end


% --- Executes on slider movement.
function slider9_Callback(hObject, eventdata, handles)
% hObject    handle to slider9 (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,'Value') returns position of slider
%        get(hObject,'Min') and get(hObject,'Max') to determine range of slider
poisson_slide=get(handles.slider9,'value');
%disp(gaussian_slide)  %测试
set(handles.edit11,'string',poisson_slide);

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

% Hint: slider controls usually have a light gray background.
if isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor',[.9 .9 .9]);
end

function edit8_Callback(hObject, eventdata, handles)
% hObject    handle to edit8 (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 edit8 as text
%        str2double(get(hObject,'String')) returns contents of edit8 as a double
gaussian_edit=get(handles.edit8,'string');
%disp(gaussian_slide)  %测试
gaussian_edit=str2num(gaussian_edit);
if gaussian_edit>0.1||gaussian_edit<0
    errordlg('输入错误,请重输!')
    error();
end
set(handles.slider6,'value',gaussian_edit);

% --- Executes during object creation, after setting all properties.
function edit8_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit8 (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 slider movement.
function slider10_Callback(hObject, eventdata, handles)
% hObject    handle to slider10 (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,'Value') returns position of slider
%        get(hObject,'Min') and get(hObject,'Max') to determine range of slider
speckle_slide=get(handles.slider10,'value');
%disp(gaussian_slide)  %测试
set(handles.edit12,'string',speckle_slide);

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

% Hint: slider controls usually have a light gray background.
if isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor',[.9 .9 .9]);
end

function edit9_Callback(hObject, eventdata, handles)
% hObject    handle to edit9 (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 edit9 as text
%        str2double(get(hObject,'String')) returns contents of edit9 as a double
salt_edit=get(handles.edit9,'string');
%disp(gaussian_slide)  %测试
salt_edit=str2num(salt_edit);
if salt_edit>0.1||salt_edit<0
    errordlg('输入错误,请重输!')
    error();
end
set(handles.slider7,'value',salt_edit);


% --- Executes during object creation, after setting all properties.
function edit9_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit9 (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 edit10_Callback(hObject, eventdata, handles)
% hObject    handle to edit10 (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 edit10 as text
%        str2double(get(hObject,'String')) returns contents of edit10 as a double
localvar_edit=get(handles.edit10,'string');
%disp(gaussian_slide)  %测试
localvar_edit=str2num(localvar_edit);
if localvar_edit>0.1||localvar_edit<0
    errordlg('输入错误,请重输!')
    error();
end
set(handles.slider8,'value',localvar_edit);

% --- Executes during object creation, after setting all properties.
function edit10_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit10 (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 edit11_Callback(hObject, eventdata, handles)
% hObject    handle to edit11 (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 edit11 as text
%        str2double(get(hObject,'String')) returns contents of edit11 as a double

poisson_edit=get(handles.edit11,'string');
%disp(gaussian_slide)  %测试
poisson_edit=str2num(poisson_edit);
if poisson_edit>0.1||poisson_edit<0
    errordlg('输入错误,请重输!')
    error();
end
set(handles.slider9,'value',poisson_edit);

% --- Executes during object creation, after setting all properties.
function edit11_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit11 (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 edit12_Callback(hObject, eventdata, handles)
% hObject    handle to edit12 (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 edit12 as text
%        str2double(get(hObject,'String')) returns contents of edit12 as a double
speckle_edit=get(handles.edit12,'string');
%disp(gaussian_slide)  %测试
speckle_edit=str2num(speckle_edit);
if speckle_edit>0.1||speckle_edit<0
    errordlg('输入错误,请重输!')
    error();
end
set(handles.slider10,'value',speckle_edit);


% --- Executes during object creation, after setting all properties.
function edit12_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit12 (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 pushbutton7.
function pushbutton7_Callback(hObject, eventdata, handles)
% hObject    handle to pushbutton7 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
global im_cover 
global im_message
global key_2

get_var_error_expression %判断是否输入密钥

disp('LSB提取')%测试
noise
myfilter
lsb_get

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

%调用载体图像、秘密信息图像和密钥的全局变量
global im_cover 
global im_message
global key_2

get_var_error_expression %判断是否输入密钥

disp('DCT提取') %测试
noise
myfilter
dct_get

% --- Executes on button press in pushbutton9.
function pushbutton9_Callback(hObject, eventdata, handles)
% hObject    handle to pushbutton9 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
global im_cover 
global im_message
global key_2
get_var_error_expression %判断是否输入密钥

disp('DWT提取') %测试
noise
myfilter
dwt_get

% --- 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 im_cover  %定义im为全局变量

%选择载体图片
[filename,pathname]=...
    uigetfile({'*.bmp'},'选择图片');

%合成路径+文件名
str=[pathname filename];

%读取图片
im_cover=imread(str);
%判断是否为灰度图像
%if ndims(im_cover)~=2
% if ~isgray(im_cover)
%     errordlg('请选择灰度图像作为载体图像');
%     error();
% end
im_cover=uint8(im_cover);
set(handles.edit1,'string',str);

% --- 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)

global im_message  %全局变量

%选择载体图片
[filename1,pathname1]=...
    uigetfile({'*.bmp'},'选择图片');

%合成路径+文件名
str=[pathname1 filename1];

%读取图片
im_message=imread(str);
%判断是否为二维二值图像
%test_message=find(im_message~=0&im_message~=1);
%if isempty(test_message)
%    test_value=0;
%else
%    test_value=1;
%end
%if ndims(im_message)~=2||test_value
%if any(im_message~=0|im_message~=1)
% if ~isbw(im_message)
%     errordlg('请选择二值图像作为秘密信息图像');
%     error();
% end

set(handles.edit2,'string',str);

% --- 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)
global im_cover
global im_message  %使全局载体图像的变量

%判断是否已经选择载体图像和秘密信息图像
if  isempty(im_cover)
    errordlg('请选择一张图片作为载体图片','错误');
    error();
end
if  isempty(im_message)
    errordlg('请选择一张图片作为秘密图片','错误');
    error();
end
%if im_message==NULL
%    errordlg('请选择载体图像');
%    error();
%end
figure
subplot(121);
imshow(im_cover);title('载体图像');
subplot(122);
imshow(im_message);title('秘密信息图像');


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


% --- 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 im_cover

if  isempty(im_cover)
  errordlg('请先执行嵌入操作!');
  error();
end
info_hidden_image_psnr=imread('info_hidden_image.bmp');

PSNR=psnr(im_cover,info_hidden_image_psnr);
%PSNR= vpa(PSNR,6);
PSNR_str_1=num2str(PSNR,'%1.4f');
PSNR_str=['PSNR=' PSNR_str_1 'dB'];
msgbox(PSNR_str)
%msgbox(num2srt(PSNR))
% --- Executes on button press in pushbutton6.
function pushbutton6_Callback(hObject, eventdata, handles)
% hObject    handle to pushbutton6 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
global im_cover
if  isempty(im_cover)
  errordlg('请先执行嵌入操作!');
  error();
end
hide_compare

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

% Hint: get(hObject,'Value') returns toggle state of radiobutton1


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

% Hint: get(hObject,'Value') returns toggle state of radiobutton2


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

% Hint: get(hObject,'Value') returns toggle state of radiobutton3


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

if exist('info_recover_image.bmp','file')==0
    errordlg('处理失败,请先提取秘密信息!');
    error();
end
message_recover=imread('info_recover_image.bmp');
nc(im_message,message_recover)


% --- Executes on button press in pushbutton11.
function pushbutton11_Callback(hObject, eventdata, handles)
% hObject    handle to pushbutton11 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
%将原始的秘密信息和恢复后的秘密信息作差值运算
global im_message

if  isempty(im_message)
  errordlg('处理失败!')
  error();
end
%message_recover_comp=imread('info_recover_image.bmp');
recover_compare

function edit13_Callback(hObject, eventdata, handles)
% hObject    handle to edit13 (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 edit13 as text
%        str2double(get(hObject,'String')) returns contents of edit13 as a double


% --- Executes during object creation, after setting all properties.
function edit13_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit13 (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 pushbutton15.
function pushbutton15_Callback(hObject, eventdata, handles)
% hObject    handle to pushbutton15 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
global key_1
key_1=get(handles.edit13,'string');
%disp(key_1)  %测试
key_1=str2double(key_1);

function edit14_Callback(hObject, eventdata, handles)
% hObject    handle to edit14 (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 edit14 as text
%        str2double(get(hObject,'String')) returns contents of edit14 as a double


% --- Executes during object creation, after setting all properties.
function edit14_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit14 (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 pushbutton16.
function pushbutton16_Callback(hObject, eventdata, handles)
% hObject    handle to pushbutton16 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
global key_2
key_2=get(handles.edit14,'string');
%disp(key_1)
key_2=str2double(key_2);

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

%调用载体图像、秘密信息图像和密钥的全局变量
global im_cover 
global im_message
global key_1

%str=get(handles.radiobutton27,'string');
hide_var_error_expression %判断全局变量是否存在


 %根据valuede返回值,调用相对应的算法进行信息隐藏
 if (get(handles.radiobutton27,'value'))
     disp('LSB算法') %测试
      lsb_hide
 elseif (get(handles.radiobutton28,'value'))
     disp('DCT算法') %测试
     dct_hide
 elseif (get(handles.radiobutton29,'value'))
      disp('DWT算法') %测试
      dwt_hide
    %case 'DWT算法'
 else
     disp('LHA算法')
     lha_hide
end


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

% Hint: get(hObject,'Value') returns toggle state of radiobutton27
handles.sel=1;
guidata(hObject, handles);

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

% Hint: get(hObject,'Value') returns toggle state of radiobutton28


% --- If Enable == 'on', executes on mouse press in 5 pixel border.
% --- Otherwise, executes on mouse press in 5 pixel border or over slider6.
function slider6_ButtonDownFcn(hObject, eventdata, handles)
% hObject    handle to slider6 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)


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

get_var_error_expression %判断是否输入密钥

disp('LHA提取')%测试
noise
myfilter
lha_get


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

if  isempty(im_cover)
  errordlg('请先执行嵌入操作!');
  error();
end
myMSE

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

if exist('info_recover_image.bmp','file')==0
    errordlg('处理失败,请先提取秘密信息!');
    error();
end
message_recover=imread('info_recover_image.bmp');
myBER


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

% Hint: slider controls usually have a light gray background.
if isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor',[.9 .9 .9]);
end

function edit15_Callback(hObject, eventdata, handles)
% hObject    handle to edit15 (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 edit15 as text
%        str2double(get(hObject,'String')) returns contents of edit15 as a double
light_edit=get(handles.edit15,'string');
%disp(gaussian_slide)  %测试
light_edit=str2num(light_edit);
if light_edit>255||light_edit<-255
    errordlg('输入错误,请输入[-255 255]之间的值!')
    error();
end
set(handles.slider11,'value',light_edit);

% --- Executes during object creation, after setting all properties.
function edit15_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit15 (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 slider movement.
function slider11_Callback(hObject, eventdata, handles)
% hObject    handle to slider11 (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,'Value') returns position of slider
%        get(hObject,'Min') and get(hObject,'Max') to determine range of slider
light_slide=get(handles.slider11,'value');
%disp(gaussian_slide)  %测试
set(handles.edit15,'string',light_slide);

 


3 运行结果

4 参考文献

[1]张大奇, 曲仕茹, 康宝生. 基于DCT和DWT的数字图像隐藏技术[J]. 西北工业大学学报, 2007, 25(3):5.

[2]徐凯. 图像信息隐藏算法研究[D]. 贵州大学.

博主简介:擅长智能优化算法、神经网络预测、信号处理、元胞自动机、图像处理、路径规划、无人机等多种领域的Matlab仿真,相关matlab代码问题可私信交流。

部分理论引用网络文献,若有侵权联系博主删除。

  • 2
    点赞
  • 23
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

打赏作者

matlab科研助手

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

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

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

打赏作者

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

抵扣说明:

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

余额充值