I am a beginner in matlab. I just used below code for embedding watermark. Can anybody tell how to extract watermark from this code??

image1=imread('aaa.jpg');
figure,imshow(image1);
title('Original image');
[ori_row,ori_col]=size(image1)
host_length=ori_row*ori_col;
i=1;
j=1;
k=1;
wmimage=imread('hand.jpg')
[wm_row,wm_col] = size(wmimage);
figure,imshow(wmimage);
title('Watermark image');
wm=dec2bin(wmimage);
wm_length=wm_row*wm_col*8;
host=dec2bin(image1);
counter=0;
while i < host_length
counter=counter+1;
if counter > wm_length
break;
end
host(i,8)=wm(j,k);
k=k+1;
if k>8
k=1;
j=j+1;
end
i=i+1;
end
key1=wm_row
key2=wm_col
im1=bin2dec(host);
im1=reshape(im1,ori_row,ori_col);
image1(1:ori_row,1:ori_col)=im1(1:ori_row,1:ori_col);
display 'After embed';
imwrite(image1,'wmarked.bmp');
figure,imshow(image1);
title('Watermarked image')

Answers (1)

Can't really read the code but I see bin2dec() and dec2bin() in there, so maybe you can use bitget(). With the bad indenting, non-descriptive single letter variable names, and lack of comments, I'm not even going to try to understand it, much less formulate some algorithm for undoing whatever it was you did.

Asked:

on 26 Jun 2015

Commented:

on 26 Jun 2015

Community Treasure Hunt

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

Start Hunting!