how to extract a watermark in matlab?
14 views (last 30 days)
Show older comments
richa sharma
on 1 Sep 2015
Commented: richa sharma
on 11 Sep 2015
the matlab code which i have used is:-
clear all; close all; clc;
bit=input('Please define which bit you want to extract from? (8 | 7 | 6 | 5)'); image=imread('C:\Users\user\Desktop\wm pictures\lena.jpg');
imshow(image);
[row,col]=size(image);
Hlength=row*col;
i=1;
j=1;
k=1; row=128;
col=384;
wmimage=imread('C:\Users\user\Desktop\wm pictures\cameraman.jpg');
wm=dec2bin(wmimage);
Wlength=row*col*8;
host=dec2bin(image);
cnt=0;
while i <= Hlength
cnt=cnt+1;
if cnt>Wlength
break;
end
wm(j,k)=host(i,bit);
k=k+1;
if k>8
k=1;
j=j+1;
end
i=i+1;
end
wm1=bin2dec(wm);
wm2=reshape(wm1,row,col);
wmimage(1:row,1:col)=wm2(1:row,1:col);
imwrite(wmimage,'extracted.jpg');
imshow(wmimage);
This code is not giving the desired result.
If anyone can give me some other codes for extraction in spatial domain then please help me out.
thank you
0 Comments
Accepted Answer
Image Analyst
on 2 Sep 2015
If your watermark is just in one bitplane, then perhaps you'd be interested in my bitplane viewer, or in my LSB watermark demo, both attached.
More Answers (1)
Walter Roberson
on 2 Sep 2015
Re-read the documentation about size() !
[d1,d2,d3,...,dn] = size(X), for n > 1, returns the sizes of the dimensions of the array X in the variables d1,d2,d3,...,dn, provided the number of output arguments n equals ndims(X). If n does not equal ndims(X), the following exceptions hold:
n < ndims(X)
di equals the size of the ith dimension of X for 0<i<n, but dn equals the product of the sizes of the remaining dimensions of X, that is, dimensions n through ndims(X).
n > ndims(X)
size returns ones in the "extra" variables, that is, those corresponding to ndims(X)+1 through n.
1 Comment
Image Analyst
on 2 Sep 2015
Of course she's hard coding in the rows and columns after she calls size() so that blows the values that the size() function returned. Not sure why she does that.
And we don't know the algorithm used to insert the watermark so we don't know if that cryptic, uncommented algorithm used to extract the watermark, or repair the original image by removing the watermark, is correct or not, but that's what the debugger is for.
See Also
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!