LSB图片信息隐藏隐藏实验 下载本文

附件: 源代码:

function varargout = LSB3333(varargin) % LSB3333 MATLAB code for LSB3333.fig

% LSB3333, by itself, creates a new LSB3333 or raises the existing % singleton*. %

% H = LSB3333 returns the handle to a new LSB3333 or the handle to % the existing singleton*. %

% LSB3333('CALLBACK',hObject,eventData,handles,...) calls the local

% function named CALLBACK in LSB3333.M with the given input arguments. %

% LSB3333('Property','Value',...) creates a new LSB3333 or raises the % existing singleton*. Starting from the left, property value pairs are

% applied to the GUI before LSB3333_OpeningFcn gets called. An % unrecognized property name or invalid value makes property application

% stop. All inputs are passed to LSB3333_OpeningFcn via varargin. %

% *See GUI Options on GUIDE's Tools menu. Choose \one

% instance to run (singleton)\ %

% See also: GUIDE, GUIDATA, GUIHANDLES

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

% Last Modified by GUIDE v2.5 14-Apr-2015 10:08:25

% Begin initialization code - DO NOT EDIT gui_Singleton = 1;

gui_State = struct('gui_Name', mfilename, ... 'gui_Singleton', gui_Singleton, ... 'gui_OpeningFcn', @LSB3333_OpeningFcn, ... 'gui_OutputFcn', @LSB3333_OutputFcn, ... 'gui_LayoutFcn', [] , ... 'gui_Callback', []); if nargin && ischar(varargin{1})

gui_State.gui_Callback = str2func(varargin{1}); end

11

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 LSB3333 is made visible.

function LSB3333_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 LSB3333 (see VARARGIN)

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

% Update handles structure guidata(hObject, handles);

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

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

function pbtCover_Callback(hObject, eventdata, handles) % hObject handle to pbtCover (see GCBO)

% eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) global gCover;

[gCover,sFile]=loadimg();

12

if isempty(gCover)

msgbox('Cover image is empty!','Warning','warn','modal'); return; end

axes(handles.axCover); imshow(gCover);

[iH iW iL]=size(gCover);

sMsg=[sFile,'[',num2str(iH),'*',num2str(iW),'*',num2str(iL),']']; set(handles.text1,'String',sMsg);

% --- Executes on button press in pbtSecret.

function pbtSecret_Callback(hObject, eventdata, handles) % hObject handle to pbtSecret (see GCBO)

% eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) global gSecret;

[gSecret ,sFile]=loadimg(); if isempty(gSecret)

msgbox('Secret image is empty!','Warning','warn','modal'); return; end

axes(handles.axSecret); imshow(gSecret);

[iH iW iL]=size(gSecret);

sMsg=[sFile,'[',num2str(iH),'*',num2str(iW),'*',num2str(iL),']']; set(handles.text1,'String',sMsg);

set(handles.text2,'String','Secret Image');

% --- Executes on button press in pbtEmbed.

function pbtEmbed_Callback(hObject, eventdata, handles) % hObject handle to pbtEmbed (see GCBO)

% eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) global gCover gSecret gStego; if isempty(gCover)

msgbox('Cover image is empty!' , 'Warning' , 'warn' , 'modal' ); return; end

if isempty(gSecret)

msgbox('gSecret image is empty!' , 'Warning' , 'warn' , 'modal' ); return;

13

end

[Hc,Wc,Lc]=size(gCover); [Hs,Ws,Ls]=size(gSecret);

if (Hc~=Hs) || (Wc~=Ws) || (Lc~=Ls) disp('Error: Not Match!' ); return; end

gStego = uint8(bitor(bitand(gCover,254),bitshift(gSecret,-7))); imwrite(gStego, '~emTmp.bmp' ); axes(handles.axStego); imshow(gStego,[]);

% --- Executes on button press in pbtExtract.

function pbtExtract_Callback(hObject, eventdata, handles) % hObject handle to pbtExtract (see GCBO)

% eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) global gStego; global gCover gSecret; if isempty(gCover)

msgbox('Cover image is empty!' , 'Warning' , 'warn' , 'modal' ); return; end

if isempty(gSecret)

msgbox('gSecret image is empty!' , 'Warning' , 'warn' , 'modal' ); return; end

[Hc,Wc,Lc]=size(gCover); [Hs,Ws,Ls]=size(gSecret);

if (Hc~=Hs) || (Wc~=Ws) || (Lc~=Ls) disp('Error: Not Match!' ); return; end

gStego = uint8(bitor(bitand(gCover,254),bitshift(gSecret,-7))); imwrite(gStego, '~emTmp.bmp' ); axes(handles.axStego); imshow(gStego,[]);

if isempty(gStego)

msgbox('Stego image is empty!' , 'Warning' , 'warn' , 'modal' ); return; end

imExtract = uint8(bitand(255,bitshift(gStego,7))); imwrite(imExtract, '~exTmp.bmp' );

14