1 LSB算法简介
LSB全称为 Least Significant Bit(最低有效位),是一种简单而有效的数据隐藏技术。LSB隐写的基本方法是用欲嵌入的秘密信息取代载体图像的最低比特位,原来的图像的高位平面与代表秘密信息的最低平面组成含隐蔽信息的新图像。
灰度化的图像为单通道格式存储像素,每个像素值在0~255内,而像素的位平面则是对应二进制的像素的各个位。以上图为例,某个像素的值为78,其二进制01001110,从左到右位权依次降低,最左边为最高有效位(MSB,其位权为 2 7 2^72
7
),最右边位最低有效位(LSB,位权为2 0 2^02
0
)。把每个像素的相同位抽取出来组成一个新的平面,就是所谓的图的位平面。而LSB隐写算法,如其名字,是在LSB也就是最低位平面进行信息嵌入/隐藏。
需要注意的一点是,LSB嵌入的时候,载体图像格式应该为灰度图格式
以著名的Lena图为例,一下是灰度图Lena原图:
下面是其各个位平面图,从左到右、从上到下位平面依次降低:
可以看到,位平面越高包含的原图像信息越多,对图像的灰度值贡献越大,并且相邻比特的相关性也越强,反之则相反。LSB最低位平面基本上不包含图像信息了,类似随机的噪点/噪声,因此,可以在此处填入水印/秘密信息。
嵌入示意图如下:
选取不同位平面嵌入时,LSB算法的保真度:
2 算法原理
通俗来讲我们看到的图片都是由一个个小的像素点来构成的,所有像素点摆在一起,构成一个大方块,这个大方块就是我们所见的图像。灰度图像(也就是我们平时所说的黑白图像)是由一层像素点组成的,而彩色图像是由三层这样的灰度图像组成的。这里拿灰度图像举例,我们之所以能在图像上看到黑色和白色,是因为每个像素点的像素值不同。0表示纯黑,255表示纯白,灰色就是由这两个数字之间的值构成。越靠近0越黑,越靠近255越白。那为什么是0和255呢?因为计算机是二进制,它会用8个比特来表示一个像素点(也可以用更多的比特,这样图像的颜色分级就越多,同时图像也会占用更大的空间,但是普通人的眼睛并不能辨认这么多的颜色,除非你异于常人),所以最大值是255,最小是0。lsb就是基于2进制这一特点来隐藏信息的,因为人眼并不是很精密的颜色或亮度的感知器,所以把像素灰度上下微调1是不会被人眼察觉的,也就是修改8位二进制码中最小的一位。当我们把图片每个像素的最后一位按照我们的想法改变,使他表现为我们想要的信息,但用户却不能看出,也不会影响图片的内容。这就是lsb数字水印。
3 LSB算法的基本特点:
LSB是一种大容量的数据隐藏算法
LSB的鲁棒性相对较差(当stego图像遇到信号处理,比如:加噪声,有损压缩等,在提取嵌入信息时会丢失)
4 常见LSB算法的嵌入方法:
秘密信息在最低位平面连续嵌入至结束,余下部分不作任何处理(典型软件MandelSteg)
秘密信息在最低位平面连续嵌入至结束,余下部分随机化处理(也称沙化处理,典型软件PGMStealth)
秘密信息在最低位平面和次低位平面连续嵌入,并且是同时嵌入最低位平面和次低位平面
秘密信息在最低位平面嵌入,等最低位平面嵌入完全嵌入之后,再嵌入次低位平面
秘密信息在最低位平面随机嵌入
以上五种方式,当嵌入容量不同时,鲁棒性不同
function varargout = untitled1(varargin) % UNTITLED1 M-file for untitled1.fig % UNTITLED1, by itself, creates a new UNTITLED1 or raises the existing % singleton*. % % H = UNTITLED1 returns the handle to a new UNTITLED1 or the handle to % the existing singleton*. % % UNTITLED1('CALLBACK',hObject,eventData,handles,...) calls the local % function named CALLBACK in UNTITLED1.M with the given input arguments. % % UNTITLED1('Property','Value',...) creates a new UNTITLED1 or raises the % existing singleton*. Starting from the left, property value pairs are % applied to the GUI before untitled1_OpeningFcn gets called. An % unrecognized property name or invalid value makes property application % stop. All inputs are passed to untitled1_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 untitled1 % Last Modified by GUIDE v2.5 11-Jan-2022 21:12:41 % Begin initialization code - DO NOT EDIT gui_Singleton = 1; gui_State = struct('gui_Name', mfilename, ... 'gui_Singleton', gui_Singleton, ... 'gui_OpeningFcn', @untitled1_OpeningFcn, ... 'gui_OutputFcn', @untitled1_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 untitled1 is made visible. function untitled1_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 untitled1 (see VARARGIN) % Choose default command line output for untitled1 handles.output = hObject; % Update handles structure guidata(hObject, handles); % UIWAIT makes untitled1 wait for user response (see UIRESUME) % uiwait(handles.figure1); % --- Outputs from this function are returned to the command line. function varargout = untitled1_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 selection change in popupmenu1. function popupmenu1_Callback(hObject, eventdata, handles) % hObject handle to popupmenu1 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Hints: contents = cellstr(get(hObject,'String')) returns popupmenu1 contents as cell array % contents{get(hObject,'Value')} returns selected item from popupmenu1 % --- Executes during object creation, after setting all properties. function popupmenu1_CreateFcn(hObject, eventdata, handles) % hObject handle to popupmenu1 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called % Hint: popupmenu 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 selection change in popupmenu2. function popupmenu2_Callback(hObject, eventdata, handles) % hObject handle to popupmenu2 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Hints: contents = cellstr(get(hObject,'String')) returns popupmenu2 contents as cell array % contents{get(hObject,'Value')} returns selected item from popupmenu2 % --- Executes during object creation, after setting all properties. function popupmenu2_CreateFcn(hObject, eventdata, handles) % hObject handle to popupmenu2 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called % Hint: popupmenu 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
1 matlab版本
2014a
2 参考文献
[1]韩纪庆,张磊,郑铁然.语音信号处理(第3版)[M].清华大学出版社,2019.
[2]柳若边.深度学习:语音识别技术实践[M].清华大学出版社,2019.