|
|
|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[WM]: Zernike Moments
Hi watermarker
I tried to make a watermarking schema that is invariant
to rotational attack so I decided to use Zernike moments as to embed the
watermark I have implemented the attached code for Zernike moments; but the
problem that the values of the Zernike moments are not matched with correct
values for example for constant gray level 127 for 128*128 image the value
of the Zernike moments is 127.24 but using my implementation it was 124.7896
for n=0 and m=0
Same for n=12 and m=12 correct value is 0.0153 but my value is 0.7069 i.e.
my value is always greater than the correct value except for n=0 and m=0.
Could you please help me to find the problem in the following matlab code?
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function [A]=calculateZernikMoment(I,n,m)
I=double(I);
V=calculateZernikePoly(I,n,m);
Vconj=conj(V);
[l w]=size(I);
Xdelta=2/(l);
Ydelta=2/(w);
A=sum(sum(Vconj.*I));
A=((n+1)/pi)*Xdelta*Ydelta*A;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function [V]=calculateZernikePoly(I,n,m)
[l w]=size(I);
V=zeros(l,w);
radialPoly=zeros(l,w);
step=2/(l-1);
[x y]=meshgrid(-1:step:1);
y=y';
y=fliplr(y);
y=y';
r=x+i*y;
rm=abs(r);
theta=angle(r);
for row=1:l
for col=1:w
rmValue=rm(row,col);
thetaValue=theta(row,col);
if(rmValue<=1.00)
radialPoly(row,col)=calculateRadialPoly(rmValue,n,m);
V(row,col)=radialPoly(row,col)*exp(i*m*thetaValue);
end
end
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function[radialPoly] =calculateRadialPoly(r,n,m)
radialPoly=0;
mAbs=abs(m);
for s=0:(n-mAbs)/2
nem=(-1)^s * nCr(n-s) * r^(n-2*s);
dem=nCr(s) * nCr(((n+mAbs)/2)-s) * nCr(((n-mAbs)/2)-s);
radialPoly=radialPoly+( nem/dem );
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function [result]=nCr(n)
result=1;
for counter=n:-1:1
result=counter*result;
end
______________________________________________________________________________
Watermarking Mailing List - http://www.watermarkingworld.org/ml.html
To unsubscribe send email to "majordomo@watermarkingworld.org" with
"unsubscribe watermarking YOURMAIL" in the body.
______________________________________________________________________________
|