Reconstuction of RGB image after embedding

조회 수: 5 (최근 30일)
Geboz Rent
Geboz Rent 2015년 1월 16일
답변: Geoff Hayes 2015년 1월 18일
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

답변 (1개)

Geoff Hayes
Geoff Hayes 2015년 1월 18일
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.

카테고리

Help CenterFile Exchange에서 Images에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by