This file is indexed.

/usr/share/octave/packages/image-2.4.1/otf2psf.m is in octave-image 2.4.1-1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  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
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
## Copyright (C) 2015 Carnë Draug <carandraug@octave.org>
##
## This program is free software; you can redistribute it and/or
## modify it under the terms of the GNU General Public License as
## published by the Free Software Foundation; either version 3 of the
## License, or (at your option) any later version.
##
## This program is distributed in the hope that it will be useful, but
## WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
## General Public License for more details.
##
## You should have received a copy of the GNU General Public License
## along with this program; if not, see
## <http://www.gnu.org/licenses/>.

## -*- texinfo -*-
## @deftypefn  {Function File} {} otf2psf (@var{otf})
## @deftypefnx {Function File} {} otf2psf (@var{otf}, @var{outsize})
## Compute PSF from OTF.
##
## Returns the Point Spread Function (OTF) of the Optical Transfer
## Function @var{otf}.
##
## The optional argument @var{outsize} defines the size of the returned
## @var{psf}.
##
## @seealso{circshift, ifft2, ifftn, psf2otf}
## @end deftypefn

function psf = otf2psf (otf, outsize)
  if (nargin < 1 || nargin > 2)
    print_usage ();
  elseif (! isnumeric (otf))
    error ("otf2psf: OTF must be numeric")
  endif
  insize = size (otf);

  psf = ifftn (otf);
  psf = circshift (psf, floor (insize / 2));

  if (nargin > 1)
    if (! isnumeric (outsize) || ! isvector (outsize))
      error ("otf2psf: OUTSIZE must be a numeric vector");
    endif
    insize = size (otf);

    n = max (numel (outsize), numel (insize));
    outsize = postpad (outsize(:), n, 1);
    insize  = postpad (insize(:) , n, 1);

    pad = (insize - outsize) / 2;
    if (any (pad < 0))
      error ("otf2psf: OUTSIZE must be smaller than or equal than OTF size");
    endif
    prepad  = floor (pad);
    postpad = ceil  (pad);

    idx = arrayfun (@colon, prepad + 1, insize - postpad,
                    "UniformOutput", false);
    psf = psf(idx{:});
  endif

endfunction

## We are assuming psf2otf is working correctly

%!function otf = rand_otf (varargin)
%!  otf = complex (rand (varargin{:}), rand (varargin{:}));
%!endfunction

## Basic usage, 1, 2, and 3 dimensional
%!test
%! otf = rand_otf (6, 1);
%! assert (otf2psf (otf), circshift (ifft (otf), 3));
%!test
%! otf = rand_otf (6, 6);
%! assert (otf2psf (otf), circshift (ifft2 (otf), [3 3]));
%!test
%! otf = rand_otf (6, 6, 6);
%! assert (otf2psf (otf), circshift (ifftn (otf), [3 3 3]));

## Test when length of some sides are odd
%!test
%! otf = rand_otf (7, 1);
%! assert (otf2psf (otf), circshift (ifft (otf), 3));
%!test
%! otf = rand_otf (7, 7);
%! assert (otf2psf (otf), circshift (ifft2 (otf), [3 3]));
%!test
%! otf = rand_otf (6, 7, 8);
%! assert (otf2psf (otf), circshift (ifftn (otf), [3 3 4]));

## Test the outsize/unpadding option
%!test
%! otf  = rand_otf (7, 1);
%! ppsf = circshift (ifft (otf), 3);
%! assert (otf2psf (otf, 6), ppsf(1:6));
%! assert (otf2psf (otf, [6 1]), ppsf(1:6));
%!test
%! otf = rand_otf (7, 7);
%! ppsf = circshift (ifft2 (otf), [3 3]);
%! assert (otf2psf (otf, [6 1]), ppsf(1:6,4));
%!test
%! otf = rand_otf (6, 7);
%! ppsf = circshift (ifft2 (otf), [3 3]);
%! assert (otf2psf (otf, [6 6]), ppsf(:,1:6));

%!error <OTF must be numeric> otf2psf ("not a otf")
%!error <OUTSIZE must be smaller than> otf2psf (rand_otf (16), 18)
%!error <OUTSIZE must be smaller than> otf2psf (rand_otf (16), [14 18])
%!error <OUTSIZE must be smaller than> otf2psf (rand_otf (16), [18 18])
%!error <OUTSIZE must be smaller than> otf2psf (rand_otf (16, 1), 18)

## Some less random tests
%!test
%! psf = fspecial ("gaussian", 16);
%! otf = psf2otf (psf);
%! assert (otf2psf (otf), psf, eps);
%!test
%! psf = rand (16);
%! otf = psf2otf (psf);
%! assert (otf2psf (otf), psf, 2*eps);
%!test
%! psf = rand (8);
%! otf = psf2otf (psf, [16 16]);
%! assert (otf2psf (otf, [8 8]), psf, 2*eps);