1, Introduction
1 Introduction to LSB algorithm
The full name of LSB is Least Significant Bit (LSB), which is a simple and effective data hiding technology. The basic method of LSB steganography is to replace the lowest bit of the carrier image with the secret information to be embedded. The high-order plane of the original image and the lowest plane representing the secret information form a new image containing hidden information.
The grayed image stores pixels in a single channel format, each pixel value is within 0 ~ 255, and the bit plane of the pixel is each bit of the corresponding binary pixel. As shown in the above figure, the value of a pixel is 78, and its binary 01001110 decreases from left to right. The leftmost is the most significant bit (MSB), and its bit weight is 2 7 2 ^ 72
7
), rightmost bit, least significant bit (LSB), bit weight 2 0 2 ^ 02
0
). The same bit of each pixel is extracted to form a new plane, which is the so-called bit plane of the graph. The LSB steganography algorithm, as its name, embeds / hides information in the LSB, that is, the lowest plane.
It should be noted that when LSB is embedded, the carrier image format should be gray image format
Taking the famous Lena diagram as an example, the following is the original gray-scale Lena diagram:
The following are the bit plans, which are lowered from left to right and from top to bottom:
It can be seen that the higher the bit plane contains more original image information, the greater the contribution to the gray value of the image, and the stronger the correlation of adjacent bits, on the contrary. The LSB lowest plane basically does not contain image information, which is similar to random noise / noise. Therefore, watermark / secret information can be filled here.
The embedding diagram is as follows:
Fidelity of LSB algorithm when different bit planes are selected for embedding:
2 algorithm principle
Generally speaking, the pictures we see are composed of small pixels. All pixels are placed together to form a large square, which is the image we see. Gray image (that is, what we usually call black-and-white image) is composed of one layer of pixels, while color image is composed of three layers of such gray images. Take the gray image as an example. The reason why we can see black and white on the image is that the pixel values of each pixel are different. 0 means pure black, 255 means pure white, and gray is composed of the value between the two numbers. The closer to 0, the darker, and the closer to 255, the whiter. So why 0 and 255? Because the computer is binary, it will use 8 bits to represent a pixel (more bits can also be used, so that the image will have more color ratings, and the image will occupy more space, but ordinary people's eyes can't recognize so many colors unless you are different from ordinary people), so the maximum value is 255 and the minimum value is 0. lsb is based on binary system to hide information. Because the human eye is not a very precise color or brightness sensor, it will not be detected by the human eye to fine tune the pixel gray up and down by 1, that is, modify the smallest bit in the 8-bit binary code. When we change the last bit of each pixel of the picture according to our idea, so that it can be displayed as the information we want, but the user can't see it and won't affect the content of the picture. This is lsb digital watermarking.
3. Basic characteristics of LSB algorithm:
LSB is a large capacity data hiding algorithm
The robustness of LSB is relatively poor (when stego image encounters signal processing, such as adding noise, lossy compression, etc., it will be lost when extracting embedded information)
4. Embedding methods of common LSB algorithms:
The secret information is continuously embedded in the lowest plane until the end, and the rest is not processed (typical software MandelSteg)
The secret information is continuously embedded in the lowest plane until the end, and the rest is randomized (also known as sanding, typical software PGMStealth)
Secret information is continuously embedded in the lowest level plane and the sub low level plane, and is embedded in the lowest level plane and the sub low level plane at the same time
The secret information is embedded in the lowest plane, and then embedded in the second lowest plane after the lowest plane is fully embedded
Secret information is randomly embedded in the lowest plane
The robustness of the above five methods is different when the embedding capacity is different
2, Partial source code
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
3, Operation results
4, matlab version and references
1 matlab version
2014a
2 references
[1] Han Jiqing, Zhang Lei, Zheng tieran Speech signal processing (3rd Edition) [M] Tsinghua University Press, 2019
[2] Liu ruobian Deep learning: Practice of speech recognition technology [M] Tsinghua University Press, 2019