will someone find an error regard this code? because my watermaked modifed/inserted only left side of host image..
Show older comments
clc;
clear all;
hi=imread('Lena.tif');
[m,n]=size(hi);
area=m*n*8;
hi=dec2bin(hi); hi;
wi=imread('cameraman (2).tif');
b=imresize(wi,1/4);
imwrite(b,'wm.tif');
wi=imread('wm.tif');
[x,y]=size(wi);
wm=dec2bin(wi);
wlength=x*y*8;
i=1; j=1; k=1;
cnt=0;
while i<area
cnt=cnt+1;
if cnt>wlength;
break;
end
hi(i,8)=wm(j,k);
k=k+1;
if k>8
k=1;
j=j+1;
end
i=i+1;
end
h1=bin2dec(hi);
[u,v]=size(h1);
h1=reshape(h1,m,n);
h1=uint8(h1);
wmm(1:m,1:n)=h1(1:m,1:n);
imshow(wmm);
imwrite(wmm,'w_image.tif');
imshow(wmm);
7 Comments
Image Analyst
on 17 Sep 2014
Is lena.tif monochrome or color? Please attach your images so we can run your code on your exact images.
SHALU SINGH
on 18 Sep 2014
I created two dummy images like this:
lena = uint8(mod(repmat(0:511, 512, 1), 256)); %should be same size and type as your lena image
imwrite(lena, 'Lena.tif'); %create dummy lena image
cameraman = uint8(repmat((0:255)', 1, 256));
imwrite(cameraman, 'cameraman (2).tif');
and then ran your script.
It produced the expected result (cameraman image is properly embedded in lena image), so either you're not using the exact same code, or the images are not as you say.
SHALU SINGH
on 18 Sep 2014
Guillaume
on 18 Sep 2014
Have you tried my example above (backup your images first, as it will overwrite them)? Does it not do what you want with the script you've posted?
Your code as written here is fine. It's not the most elegant but it does what you want. I wouldn't convert to binary strings and back and would rather use bitget and bitset but as I said, what you have works.
SHALU SINGH
on 18 Sep 2014
Edited: SHALU SINGH
on 18 Sep 2014
Guillaume
on 18 Sep 2014
Sorry I made a typo the third line should have read:
cameraman = uint8(repmat((0:255)', 1, 256));
I've edited the comment to correct the error.
Answers (0)
Categories
Find more on Watermarking in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!