Discover MakerZone

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

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

New to MATLAB?

Thread Subject:
LSB watermarking using MATLAB

Subject: LSB watermarking using MATLAB

From: sayran

Date: 10 Nov, 2012 18:17:29

Message: 1 of 1

I am trying to write some code to hide a image in another image using the images LSB and MSB. My problem is i have found the LSB and MSB to use and i have added them up but the message picture isnt hidden. I have taken the message image MSB and substitued it with the LSB of the Cover image. I have tried adding the array up but the Message is still visible.

need help and thanks

This is my code

Cover = imread ( 'cameraman.tif' )
Message = imread('pout.tif');

nrows = max(size(Cover,1), size(Message,1));
ncols = max(size(Cover,2), size(Message,2));
nchannels = size(Cover,3);

extendedI1 = [ Cover, zeros(size(Cover,1), ncols-size(Cover,2), nchannels);
  zeros(nrows-size(Cover,1), ncols, nchannels)];

extendedI2 = [ Message, zeros(size(Message,1), ncols-size(Message,2), nchannels);
  zeros(nrows-size(Message,1), ncols, nchannels)];


imshow (Cover) ;
hold on
B1_c = bitget(Cover,1)*2^0;
B2_c = bitget(Cover,2)*2^1;
B3_c = bitget(Cover,3)*2^2;
B4_c = bitget(Cover,4)*2^3;
B5_c = bitget(Cover,5)*2^4;
B6_c = bitget(Cover,6)*2^5;
B7_c = bitget(Cover,7)*2^6;
B8_c = bitget(Cover,8)*2^7;

hold on
B1_m = bitget(Message,1)*2^0;
B2_m = bitget(Message,2)*2^1;
B3_m = bitget(Message,3)*2^2;
B4_m = bitget(Message,4)*2^3;
B5_m = bitget(Message,5)*2^4;
B6_m = bitget(Message,6)*2^5;
B7_m = bitget(Message,7)*2^6;
B8_m = bitget(Message,8)*2^7;

%bitplane = [ B8_c+ B7_c+ B6_c+ B5_c+ B4_c+ B3_c+ B2_c+ B1_c ];
bitplane = [ B8_c B7_c B6_c B5_c B4_c B8_m B7_m B6_m ];
%p1 = [ B8_m B7_m B6_m ];
%bitplane=B8_c+ B7_c+ B6_c+B5_c+B4_c+B8_m+ B7_m+ B6_m;

bitplane1 = Im(bitplane);
imshow(bitplane1,[0 1]);

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us