A list,

1 Introduction to LSB algorithm

LSB stands for Least Significant Bit. It is a simple and effective data hiding technique. The basic method of LSB steganography is to replace the lowest bit of the carrier image with the secret information to be embedded, and the high plane of the original image and the lowest plane representing the secret information constitute a new image containing hidden information.



The grayed image stores pixels in a single-channel format, with each pixel value ranging from 0 to 255, and the bit plane of the pixel is the bits of the corresponding binary pixel. In the example above, a pixel with a value of 78 is binary 01001110, and its bit weight decreases from left to right, with the leftmost significant bit (MSB) having a bit weight of 2 72 ^72

7

), the rightmost bit is the least significant bit (LSB, the bit weight is 2 02 ^02

0

). The same bits of each pixel are extracted to form a new plane, which is called the bit plane of the map. The LSB stegographic algorithm, as its name suggests, is to embed/hide information in the LSB, the lowest order plane.

It should be noted that when LSB is embedded, the carrier image format should be grayscale

Taking the famous Lena graph as an example, the following is the original Lena grayscale image:



Here is the bitplane, descending from left to right and from top to bottom:



It can be seen that the higher the bit plane is, the more information of the original image is contained, the greater the contribution to the gray value of the image is, and the stronger the correlation between adjacent bits is; otherwise, the opposite is true. LSB lowest level plane basically does not contain image information, similar to random noise/noise, so you can fill in watermark/secret information here.

The embedding diagram is as follows:



When different bit plane embedding is selected, the fidelity of LSB algorithm is as follows:

2 Algorithm Principle

Generally speaking, all the pictures we see are made up of small pixel points. All the pixel points are put together to form a big square, and this big square is the image we see. A grayscale image is made up of one layer of pixels, while a color image is made up of three layers of such grayscale images. In the case of grayscale images, the reason we can see black and white is because each pixel has a different pixel value. Zero is pure black, 255 is pure white, and gray is the value between these two numbers. The closer you get to 0, the darker you get, and the closer you get to 255, the whiter you get. So why 0 and 255? Because the computer is binary, it will use 8 bits to represent a pixel (you can also use more bits, so the more the color of the image classification, image will occupy more space at the same time, but the eyes of ordinary people do not recognize so much color, different from ordinary people unless you), so the maximum value is 255, the lowest is 0. LSB is based on the characteristics of binary system to hide information, because the human eye is not a very precise color or brightness perceptron, so the pixel gray level is adjusted up and down by 1 will not be detected by the human eye, that is, the smallest bit in the 8-bit binary code is modified. When we change the last digit of each pixel of the picture according to our idea, so that it represents the information we want, but the user cannot see it, and it will not 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 the Stego image encounters signal processing, such as adding noise, lossy compression, etc., it will be lost in the extraction of embedded information)

4. Common LSB algorithm embedding methods:

The secret information is continuously embedded in the lowest plane until the end, and the rest of it is not processed (typical software MandelSteg).

The secret information is continuously embedded in the lowest level plane until the end, and the rest is randomized (also known as sand treatment, typical software PGMStealth).

The secret information is continuously embedded in the lowest – order plane and the second – order plane, and is simultaneously embedded in the lowest – order plane and the second – order plane

The secret information is embedded in the lowest order plane, and after the lowest order plane is fully embedded, it is embedded in the lower order plane

The secret information is randomly embedded in the lowest order plane

The above five methods have different robustness when the embedding capacity is different

Ii. Source code

clc; clear all; fid=fopen('1.wav','r'); % read audio file oa=fread(fid,inf,'uint8'); fclose(fid); n=10; %n = length of a, 10 d=randsrc(1,n,[0,1]); % generate random sequence that is the watermark M= OA; for i=45:45+n-1 M(i)=bitset(M(i),1,d(i-44)); % Insert LSB watermark end unction A=Vector2Matrix(oi,row) % Transform the array into A two-dimensional array,row is the number of rows cl= Length (OI)/row; A=zeros(row,cl); for i=1:row for j=1:cl end end marklength=5394; % Size of extracted watermark image, row=58; Fid =fopen('marked. Wav ','r'); oa=fread(fid,inf,'uint8'); status=fseek(fid,44,'bof'); a=fread(fid,marklength,'uint8'); for i=1:marklength w1(i)=bitget(a(i),1); end w1=w1'; m=Vector2Matrix(w1,row); imwrite(m,'markedbupt.bmp','bmp'); figure; imshow('markedbupt.bmp'); title('extracted watermark'); fid=fopen('2.wav','rb'); oa=fread(fid,inf,'uchar'); n=length(oa)-44; %wav The file contains 44 bytes from the file header to the front of the data. io=imread('bupt.bmp'); [row,col]=size(io); io=io'; wi=io(:); If row*col>n error(' carrier is too small, please change carrier '); end markedaudio=oa; marklength=row*col; Fprintf (' the length of the embedded image is: %.0d\n',marklength); for k=1:row*col markedaudio(44+k)=bitset(markedaudio(44+k),1,wi(k)); endCopy the code

Third, the operation result



Fourth, note