I am a beginner in matlab. I just used below code for embedding watermark. Can anybody tell how to extract watermark from this code??
Show older comments
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')
2 Comments
Image Analyst
on 26 Jun 2015
Walter Roberson
on 26 Jun 2015
Cross reference to http://uk.mathworks.com/matlabcentral/answers/225493-can-anybody-explain-what-is-the-logic-of-the-while-loop-which-is-used-in-the-below-code-i-am-a-beg in which the poster asks for the same code to be explained.
Answers (1)
Image Analyst
on 26 Jun 2015
0 votes
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.
Categories
Find more on Watermarking in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!