MATLAB Answers

Abhinaba Das

How to replace a bit plane in an image with a bit plane of another image?

Asked by Abhinaba Das
on 29 Mar 2013

Hello, To implement digital watermarking I want to replace 3 LSB bitplanes of asset image with 3 MSB bitplanes of message image but I doubt whether my code is correct. Below is the code I have written.

asset = imread('C:\asset.jpg'); 
orig = imresize(asset,[480 640]); 
BI0 = bitget(orig,1)*(2^0);
BI1 = bitget(orig,2)*(2^1);
BI2 = bitget(orig,3)*(2^2);
BI3 = bitget(orig,4)*(2^3);
BI4 = bitget(orig,5)*(2^4);
BI5 = bitget(orig,6)*(2^5);
BI6 = bitget(orig,7)*(2^6);
BI7 = bitget(orig,8)*(2^7);
msg = imresize(wm,[480 640]);
BW0 = bitget(msg,1)*(2^0);
BW1 = bitget(msg,2)*(2^1);
BW2 = bitget(msg,3)*(2^2);
BW3 = bitget(msg,4)*(2^3);
BW4 = bitget(msg,5)*(2^4);
BW5 = bitget(msg,6)*(2^5);
BW6 = bitget(msg,7)*(2^6);
BW7 = bitget(msg,8)*(2^7);

When I am using the command imshow(watermark) the effect of message picture is very much pronounced it's not getting hidden in the asset image. Please help me. Thanks in advance.



No products are associated with this question.

1 Answer

Answer by Walter Roberson
on 29 Mar 2013

Don't forget to uint8() the watermarked result


Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi test

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

MATLAB Academy

New to MATLAB?

Learn MATLAB today!