Reconstuction of RGB image after embedding

1 visualizzazione (ultimi 30 giorni)
Geboz Rent
Geboz Rent il 16 Gen 2015
Risposto: Geoff Hayes il 18 Gen 2015
I'm currently preforming LSB operations on RGB image for each channel
But I'm confused on the way to reconstruct the image after manipulating the LSB bits
%Load Cover Image 24-bit RGB
Cover_Image=imread('RGB_24bits_palette_sample_image.jpg');
% Extract the individual red, green, and blue color channels.
redChannel = Cover_Image(:, :, 1);
greenChannel = Cover_Image(:, :, 2);
blueChannel = Cover_Image(:, :, 3);
% Get LSB's of each pixel for every channel.
redLsb = rem(redChannel, 2);
greenLsb = rem(greenChannel, 2);
blueLsb = rem(blueChannel, 2);
%Resizing the LSB into vector
redLsbVector = reshape(redLsb.',1,[]);
greenLsbVector = reshape(greenLsb.',1,[]);
blueLsbVector = reshape(blueLsb.',1,[]);
%Load Hidden message
HiddenMessage = 'Hello';
%Convert Hidden message to Binary
HiddenMessageInBinary = reshape(dec2bin(HiddenMessage, 8)', 1, []) - '0';
%Start Embedding
MissMatchCount = 0;
for i=1:length(HiddenMessageInBinary)
if redLsbVector(i)~= HiddenMessageInBinary(i)
MissMatchCount=MissMatchCount+1;
%embed
redLsbVector(i) = HiddenMessageInBinary(i);
end
end
%Reconstruct the image

Risposte (1)

Geoff Hayes
Geoff Hayes il 18 Gen 2015
Geboz - rather than updating the redLsbVector every time that you are changing a bit (because of the message), why not just update the redChannel data directly? You would first need to remove the transpose operation that occurs during the reshaping, so this code would now become
redLsbVector = reshape(redLsb,1,[]);
greenLsbVector = reshape(greenLsb,1,[]);
blueLsbVector = reshape(blueLsb,1,[]);
Then, the embedding of the message code changes to
for i=1:length(HiddenMessageInBinary)
if redLsbVector(i)~= HiddenMessageInBinary(i)
MissMatchCount=MissMatchCount+1;
% change the least significant bit of the ith byte
redChannel(i) = bitxor(redChannel(i),1);
end
end
After the above code (so try with a breakpoint), you should be able to observe that HiddenMessageInBinary is identical to
redLsb = rem(redChannel, 2);
redLsb(1:40)
which suggests that we have embedded the message correctly in these first 40 bytes of the red channel.

Categorie

Scopri di più su Image Processing Toolbox in Help Center e File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by