Text extraction from image using LSB based steganography
Prerequisite: LSB based Image steganography using MATLAB
In LSB based Image steganography using MATLAB, we saw how to hide text inside an image. In this article, we are going to see given the stego image or the pixel values and the length of the text embedded as input, how to extract the text from it.
The extraction process is simple. We need to first calculate how many pixels is the text stored in. For example, the text “geeksforgeeks” has 13 characters. Each character is represented in 8 bits. So, the number of pixels in which the text is stored will be 13 * 8 = 104. Now after knowing this, we need to traverse through the image, one pixel at a time. We store the Least Significant Bit (LSB) of each pixel in an array extracted_bits. After extracting the LSBs of the required pixels, we need to take every 8 bits from extracted_bits and convert it to the corresponding character. In this way, the text stored in the stego image can be extracted.
In this article, we take the pixel values of the image obtained in the prerequisite article. The values are stored in xlsx format. The message embedded in the image is “geeksforgeeks”.
Note: To store the output image pixels into .xlsx format, add the following lines of code to the end of the previous code:
Here is a screenshot of the input image and the stego image obtained from the prerequisite article:
Input : A screenshot of the pixel values of the image:
Output : geeksforgeeks
The input file in xlsx format is given here: input_image.xlsx
Below is the implementation in MATLAB:
As we can see the output, the text was extracted from the pixel values and result was displayed to the command window.
Please Login to comment...