function [out, vmax] = psf(inp, vref);
% PSF
%
% [out, vmax] = psf(inp) generates the normalized point spread function
%
% inp input image
% out output image (normalized to unity)
% vmax normalization parameter
%
% [out, vmax] = psf(inp,vref) uses vref to normalize the output.
% vmax is then the ratio of the maximum value to the reference value.

% Author: John S. Loomis (15 March 2000)

f = fft2(inp);
f = fftshift(f);
out = f.*conj(f);
vmax = max(out(:));
if (nargin>1)
    out = out/vref;
    vmax = vmax/vref;
else
    out = out/vmax;
end


Maintained by John Loomis, last updated 15 March 2000