File: PsfToLsf.m

package info (click to toggle)
psychtoolbox-3 3.0.19.14.dfsg1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 86,796 kB
  • sloc: ansic: 176,245; cpp: 20,103; objc: 5,393; sh: 2,753; python: 1,397; php: 384; makefile: 193; java: 113
file content (32 lines) | stat: -rw-r--r-- 959 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
function lsf = PsfToLsf(psf,varargin)
%PSFTOLSF  Convert a line spread function to a point spread function
%    lsf = PSFTOLSF(psf,varargin)
%
%    This works by convolving a horizontal line with a psf and returning the
%    vertical slice through the center.  The spatial support of the lsf is
%    equal to the spatial support of the vertical slice through the passed
%    psf.  The passed psf should be square.
%
%    The returned lsf is normalized to have a peak amplitude of 1.
%
%    See also LSFTOPSF.

% Get passed row and column dimension.
[m,n] = size(psf);
if (m ~= n)
    error('Passed psf should have square support.')
end
centerPosition = floor(m/2)+1;

% Create a 2D image of a line across the center row.
aLine2D = zeros(size(psf));
aLine2D(centerPosition,:) = 1;

% Convolve with the psf
aLineConvolved = conv2(aLine2D,psf,'same');

% Extract the center column and normalize
lsf = aLineConvolved(:,centerPosition);
lsf = lsf/max(lsf(:));

end