/usr/share/octave/packages/image-2.6.1/radon.m is in octave-image 2.6.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 | ## Copyright (C) 2007 Alexander Barth <barth.alexander@gmail.com>
##
## 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} {[@var{RT},@var{xp}] =} radon(@var{I}, @var{theta})
## @deftypefnx {Function File} {[@var{RT},@var{xp}] =} radon(@var{I})
##
## Calculates the 2D-Radon transform of the matrix @var{I} at angles given in
## @var{theta}. To each element of @var{theta} corresponds a column in @var{RT}.
## The variable @var{xp} represents the x-axis of the rotated coordinate.
## If @var{theta} is not defined, then 0:179 is assumed.
## @end deftypefn
function [RT,xp] = radon (I,theta)
## Input checking
if (nargin == 0 || nargin > 2)
print_usage ();
elseif (nargin == 1)
theta = 0:179;
endif
if (! isnumeric (I) || ndims (I) != 2)
error("radon: I must be a MxN numeric matrix");
endif
if (!isvector(theta))
error("radon: second input must be a vector");
endif
[m, n] = size (I);
# center of image
xc = floor ((m+1)/2);
yc = floor ((n+1)/2);
# divide each pixel into 2x2 subpixels
d = reshape (I,[1 m 1 n]);
d = d([1 1],:,[1 1],:);
d = reshape (d,[2*m 2*n])/4;
b = ceil (sqrt (sum (size (I).^2))/2 + 1);
xp = [-b:b]';
sz = size(xp);
[X,Y] = ndgrid (0.75 - xc + [0:2*m-1]/2,0.75 - yc + [0:2*n-1]/2);
X = X(:)';
Y = Y(:)';
d = d(:)';
th = theta*pi/180;
for l=1:length (theta)
# project each pixel to vector (-sin(th),cos(th))
Xp = -sin (th(l)) * X + cos (th(l)) * Y;
ip = Xp + b + 1;
k = floor (ip);
frac = ip-k;
RT(:,l) = accumarray (k',d .* (1-frac),sz) + accumarray (k'+1,d .* frac,sz);
endfor
endfunction
%!test
%! A = radon(ones(2,2),30);
%! assert (A,[0 0 0.608253175473055 2.103325780167649 1.236538105676658 0.051882938682637 0]',1e-10)
|