90 likes | 281 Views
EE3190 Optical Sensing and Imaging. Computing PSFs with a digital computer. Sampling the Pupil Function. For square arrays (equal number of samples in both dimensions), select the sample spacing so that the pupil function fills up half of the array:.
E N D
EE3190 Optical Sensing and Imaging Computing PSFs with a digital computer
Sampling the Pupil Function For square arrays (equal number of samples in both dimensions), select the sample spacing so that the pupil function fills up half of the array: When using the FFT it is good practice to select N to be even. Better yet, is to selectN to be a power of 2. D is the pupil diameter in meters N is the number of samples across the array
Sampling the Pupil Function • Create a sampling grid
Sampling the Pupil Function • Create a sampling grid d2 = 2*D/N; u = [-N/2:1:N/2-1]*d2; [u1,u2] = meshgrid(u); example: d2 = 1/2; N = 6 -1.5000 -1.0000 -0.5000 0 0.5000 1.0000 u -1.5000 -1.0000 -0.5000 0 0.5000 1.0000 -1.5000 -1.0000 -0.5000 0 0.5000 1.0000 -1.5000 -1.0000 -0.5000 0 0.5000 1.0000 -1.5000 -1.0000 -0.5000 0 0.5000 1.0000 -1.5000 -1.0000 -0.5000 0 0.5000 1.0000 -1.5000 -1.0000 -0.5000 0 0.5000 1.0000 -1.5000 -1.5000 -1.5000 -1.5000 -1.5000 -1.5000 -1.0000 -1.0000 -1.0000 -1.0000 -1.0000 -1.0000 -0.5000 -0.5000 -0.5000 -0.5000 -0.5000 -0.5000 0 0 0 0 0 0 0.5000 0.5000 0.5000 0.5000 0.5000 0.5000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 u1 u2
Sampling the Pupil Function • Example: Square Pupil (DxD meters) • Example: Circular Pupil (diameter: D meters) p = (abs(u1)<=D/2)&(abs(u2)<=D/2); r = sqrt(u1.^2 + u2.^2); p = r<=D/2;
1 1 2 2 3 3 4 4 Compute the PSF • Using the FFT algorithm P = fftshift(fft2(fftshift(p)); d1 = lambda*d/(N*d2); u = [-N/2:1:N/2-1]*d1; lambda is wavelength d is distance to object or image fftshift
Example: Circular pupil D = 1; lambda = 1e-6; do = 10e3; N = 256; d2 = 2*D/N; u = [-N/2:1:N/2-1]*d2; [u1,u2] = meshgrid(u); r = sqrt(u1.^2+u2.^2); p = abs(r)<=D/2; figure(1); colormap(gray); subplot(2,1,1); imagesc(u,u,p); axis image; P = fftshift(fft2(fftshift(p))); d1 = lambda*do/(N*d2); x = [-N/2:1:N/2-1]*d1; subplot(2,1,2); imagesc(x,x,abs(P)); axis image;
Example: Circular pupil D = 1; lambda = 1e-6; do = 10e3; N = 256; d2 = 2*D/N; u = [-N/2:1:N/2-1]*d2; [u1,u2] = meshgrid(u); r = sqrt(u1.^2+u2.^2); p = abs(r)<=D/2; figure(1); colormap(gray); subplot(2,1,1); imagesc(u,u,p); axis image; P = fftshift(fft2(fftshift(p))); d1 = lambda*do/(N*d2); x = [-N/2:1:N/2-1]*d1; subplot(2,1,2); imagesc(x,x,abs(P)); axis image; axis([-1 1 -1 1]*10*lambda*do/D);
Example: Circular pupil (defocus) D = 1; lambda = 1e-6; do = 10e3; di = 10e-2; f = 1/(1/do + 1/di); ferror = 1/(1/(do*1.06) + 1/di); N = 256; d2 = 2*D/N; u = [-N/2:1:N/2-1]*d2; [u1,u2] = meshgrid(u); r = sqrt(u1.^2+u2.^2); p = (abs(r)<=D/2).*... exp(-j*(pi/(lambda*f))*r.^2).*... exp(j*(pi/(lambda*ferror))*r.^2); figure(1); colormap(gray); subplot(2,1,1); imagesc(u,u,angle(p)); axis image; P = fftshift(fft2(fftshift(p))); d1 = lambda*do/(N*d2); x = [-N/2:1:N/2-1]*d1; subplot(2,1,2); imagesc(x,x,abs(P)); axis image; axis([-1 1 -1 1]*8*lambda*do/D);