Looks promising but I'm having a problem duplicating the LASIK example...I copied the lasik image and edited out the the lasik portion -- but all I get from the following is a big red blob -- not a decent reconstructed image...anybody know what's wrong?
image=imread('zk_fig2_w.jpg');
figure(1);
I=im2double(image);
imagesc(image);
% make grid coordinate matrices expressed in polar coordinates
L = size(I,1);
X = -1:2/(L-1):1;
[x,y] = meshgrid(X);
x=x(:);
y=y(:);
[theta,r] = cart2pol(x,y);
% Compute the required degree and order values from n=0-7, inclusive
N = [];
M = [];
for n=0:7
N = [N n*ones(1,n+1)];
M = [M -n:2:n];
end
is_in_circle = ( r <= 1);
Z = zernfun(N,M,r(is_in_circle),theta(is_in_circle));
a = Z\I(is_in_circle);
% Reconstruct image using Zernike coefficients
r=NaN(size(I));
r(is_in_circle) = Z*a;
% rescale to 0-255 to display image
figure(2);
r = im2uint8(im2double(r));
imshow(r);

Hi,
Thanks for providing these files to the comunity !
However, did you check the othogonality of the functions created?
It seems to me that something's wrong there.
I generated 2 polynoms like it is shown in the doc :
z(idx) = zernfun(3,1,r(idx),theta(idx));
z2(idx) = zernfun(4,0,r(idx),theta(idx));
When I check the orthogonality by simply doing :
sum(sum(z(idx).*z2(idx)))
the result is not 0.
Am I doing someting wrong or is there a pb here?
Thanks in adavnce

Comment only

26 Mar 2013

Zernike polynomials
Zernike polynomials and functions (orthogonal basis on the unit circle).

12 Jun 2012 @JUAN CARDENAS
n = floor((-1+sqrt(1+8*p))/2);
m=-(n-2*p+n.*(n+1));
Very good solution for using any p but
I think you were missing a '-'sign for your definition of m. (can be seen when plotting the Zernike-Polynomials)

Comment only

12 Jun 2012

Zernike polynomials
Zernike polynomials and functions (orthogonal basis on the unit circle).

Thank you Paul.
An update for enabling any P order, in zernfun2, instead of:
n = ceil((-3+sqrt(9+8*p))/2);
m = 2*p - n.*(n+2);
change it by:
n = floor((-1+sqrt(1+8*p))/2);
m=n-2*p+n.*(n+1);

5

14 Nov 2011

Zernike polynomials
Zernike polynomials and functions (orthogonal basis on the unit circle).

Comment only