Extracting a hidden message from an image by using LSB algorithm
Mostrar comentarios más antiguos
I have an image that has a hidden message embedded in it, which should be extracted by using the LSB algorithm. However, the extracted hidden message that I obtained through the attached code does not make sense. It would be appreciated if anyone could point out what I am doing wrong here.
I used the following code to extract the hidden message:
s = imread('image_result.bmp');
height = size(s,1);
width = size(s,2);
m = double( s(1:1:1) ) * 8 ;
k = 1;
for i = 1 : height
for j = 1 : width
if (k <= m)
b(k) = mod(double(s(i,j)),2);
k = k + 1;
end
end
end
binaryVector = b;
binValues = [ 128 64 32 16 8 4 2 1 ];
binaryVector = binaryVector(:);
if mod(length(binaryVector),8) ~= 0
error('Length of binary vector must be a multiple of 8.');
end
binMatrix = reshape(binaryVector,8,[]);
textString = char(binValues*binMatrix);
disp(textString);
And the extracted message that I got:
6 comentarios
DGM
el 16 de Mayo de 2021
If you just look at the image, you can see the encoded block:
inpict = imread('lsbwm.bmp');
bp = mod(inpict,2);
imshow(double(bp))

My guess based on the vector length (476b) is that the message is probably encoded in 7 bpc instead of 8. How it's arranged across channels is anybody's guess.
DGM
el 17 de Mayo de 2021
I don't know. I assume that the encoded block would be arranged into a single row like
bp = flipud(bp(end-1:end,:,:));
bp = [bp(1,:,:) bp(2,:,:)];
but even if that's a correct assumption, that still leaves a lot of unknowns. Is the data arranged along channels (RRRRRR...GGGGGG....BBBBBB...) or across channels (RGBRGBRGB or some other sequence)? Is it 8b per char or 7b? What's the bit order? Are we to assume that the values are ASCII? What if it's something else? What if an offset had been applied?
Just playing around with it for a few minutes, I didn't see anything obvious, but the big zero block at the beginning of the stripe makes me curious. I'm assuming that the first few bits encode something meaningful for the process of decoding.
Rik
el 21 de Mayo de 2021
Regarding your flag ("This is a school assignment. That's why this question should be removed."): This is a public forum. You can get help here with your homework, but you should not hand in the work of others as you own. That is academic fraud and could (and should, IMHO) get you expelled from your university.
If you posted copyrighted content, you should not have done so. You should not post things on a public forum if you are not sure if you're allowed to.
I have made a capture of this page to the Wayback Machine in case you try to vandalize it, but it seems I'm already too late.
Shahrin Rahman
el 1 de Jun. de 2021
Rik
el 1 de Jun. de 2021
You already gave people permission to copy your code when you posted your question:
"You agree that Content that you contribute to Discussions will be licensed under the Creative Commons Attribution Share Alike 3.0 license." [Terms of Use]
If people pass off your code as their own they are violating the attribution part of the CC license, and they are probably commiting academic fraud. Neither of the two is necessarily your problem. If you didn't want your work being public, you shouldn't have posted it.
Rena Berman
el 29 de Jun. de 2021
(Answers Dev) Restored edit
Respuesta aceptada
Más respuestas (1)
Image Analyst
el 16 de Mayo de 2021
1 voto
Maybe you're not extracting the hidden message in the proper way for the way that they hid it in the image. Do you have the code that was used to hide the watermark message in the cover image?
I'm attaching two demos for you to study and adapt if you want.
5 comentarios
Shahrin Rahman
el 16 de Mayo de 2021
Editada: Shahrin Rahman
el 21 de Mayo de 2021
Image Analyst
el 16 de Mayo de 2021
Well you can get the LSB of an image with bitget(). See attached demo. But since it's not an image, but a text, you're going to have to take every 8 pixels (either in a row or column) and convert it to an ASCII character or a unicode character. You might have to try all 4 permutations to see which way gives sensible text. Then when you see the text stop making sense, that is probably where the hidden image ends and where the normal image values begin. I think you can do it, right?
Shahrin Rahman
el 17 de Mayo de 2021
faiz ul amin
el 20 de Abr. de 2024
hello i need some help
Image Analyst
el 20 de Abr. de 2024
@faiz ul amin If you have any questions, then ask them in a new discussion thread, and attach your data and code to read it in with the paperclip icon after you read this:
Categorías
Más información sobre Neuromicroscopy en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
