img1 = imread('exp.bmp');
N = 4;
img =double(img1);
S = size(img, 1);
xstep = 2/(S-1);
[X ,Y] = meshgrid(0:xstep:1,0:xstep:1);
Rd = sqrt((2.*X-S+1).^2+(S-1-2.*Y).^2)/S;
theta = atan((S-1-2.*Y)/ (2.*X-S+1));
Rd = (Rd<=1).*Rd;
imshow(Rd);
Rd =[Rd(:)];
theta =[theta(:)];
Rad = pseudo_zernike_radial_polynomials(N, Rd);
op =[];
vectr = [];
prodc = [];
PZm = [];
psi = [];
arc = atan((S/2-10)/(S-20));
a = S-20;
b = S/2-10;
na = 20;
nb = S/2+10;
ay = 20;
nay = S-20;
bx = S/2+10;
nbx = S/2-10;
for m=0:N
if mod(m,2)==0
x1 = img(a,b)+img(na, nb);
x2 = img(a, nb) +img(na,b);
y1 = ((-1)^m/2)*(img(nbx, ay)+img(bx, nay));
y2 = ((-1)^m/2)*(img(bx, ay)+img(nbx, nay));
psii = cos (m*arc)*(x1+y1+x2+y2)-1j*sin(m*arc)*(x1+y1-x2-y2);
else
x1 = img(a,b)-img(na, nb);
x2 = img(a, nb) -img(na,b);
y1 = ((-1)^m/2)*(img(nbx, ay)-img(bx, nay));
y2 = ((-1)^m/2)*(img(bx, ay)-img(nbx, nay));
psii = cos(m*arc)*(x1+x2)+sin(m*arc)*(y1-y2)+1j*(cos(m*arc)*(y1+y2)-sin(m*arc)*(x1-x2));
end
psi =[psi,psii];
end
for ord = 0:N
for lpsi =1:length(psi)
prod = psi(lpsi).*Rad(ord+1,:)';
prodc = [prodc, prod];
PZmn = ((N+1)/pi)*sum(sum(prodc(:, ord+1)));
PZm = [PZm; PZmn];
end
end
0 Comments
Sign in to comment.