No BSD License  

Highlights from
Airy Function Generator

image thumbnail
from Airy Function Generator by Dan Burke
Produces and Airy Pattern

CircSignal(dim,radius,mag,pos)
%this is a function to generate a circular disc
%the function the preforms a FT on the Circle and
%then displays the airy disc
function img = CircSignal(dim,radius,mag,pos)
%
% img = CircSignal(dim,radius,mag,[pos])
%
% Generate a circular disk signal image with dimension 'dim', 
% radius in pixels, and mag specifying the gray level value.
% 'pos' is an optional argument specigying the position of the
% center of the circ.  The center of the image is default.
%
if (length(dim) == 1)
  dim = [dim dim];
end

if (nargin == 3)
  % the flip is because we use (x,y) coordinates
  pos = fliplr((dim - [1 1]) / 2);
end

x = 0:(dim(2)-1);
y = 0:(dim(1)-1);

[X,Y]=meshgrid(x,x);

r = sqrt( (X-pos(1) ).^2 + (Y-pos(2) ).^2);

img = mag * (r<=radius);

%folling lines of code perform a Fourier Transform on the circle
%which is zero padded at double the array size

F = fft2(img,512,512);

H = abs(F);

G = log(H);

%the components of the FT are then inverted to give an airy disc

I = ifftshift(G);

imshow(I,[0 10],'InitialMagnification','fit');colormap(jet); colorbar

Contact us at files@mathworks.com