-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathctRadon.m
More file actions
59 lines (49 loc) · 1.8 KB
/
Copy pathctRadon.m
File metadata and controls
59 lines (49 loc) · 1.8 KB
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
function sinogram = ctRadon( img, delta, nDetectors, dSize, thetas )
% sinogram = ctRadon( img, delta, nDetectors, dSize, thetas )
%
% computes the Radon transform using the physical units of an computed
% tomography detector
%
% Inputs:
% img: 2D array - will take the Radon transform of this image
% delta: horizontal and vertical size of pixel (assumed square)
% nDetectors: the number of detectors
% thetas: a 1D array, each element is the angle that corresponds to row
% radon domain
%
% Written by Nicholas Dwork - Copyright 2013
%
% https://github.com/ndwork/dworkLib.git
%
% This software is offered under the GNU General Public License 3.0. It
% is offered without any warranty expressed or implied, including the
% implied warranties of merchantability or fitness for a particular
% purpose.
dOffset=0; % center channel offset
nTheta = numel( thetas );
dLocs = ( (0:nDetectors-1) - floor(0.5*nDetectors) ) * dSize - dOffset;
Ny = size( img, 1 ); halfY = Ny/2;
Nx = size( img, 2 ); halfX = Nx/2;
xs = ones(Ny,1) * (1:Nx);
ys = (1:Ny)' * ones(1,Nx);
xs = xs - halfX;
ys = ys - halfY;
radiusMask = sqrt( xs.*xs + ys.*ys ) < min(Nx/2,Ny/2);
radiusImg = img .* radiusMask;
if mod( Nx, 2 )==0
locs = ( (0:Nx-1) - 0.5*Nx + 0.5 ) * delta;
else
locs = ( (0:Nx-1) - floor(0.5*Nx) ) * delta;
end
sinogram = zeros( nTheta, nDetectors );
parfor th = 1 : numel( thetas )
theta = thetas( th );
rotated = rotImg( radiusImg, theta );
sumResult = sum( rotated, 1 ) * delta;
interped = interp1( locs, sumResult, dLocs, 'linear', 0 );
sinogram(th,:) = interped;
if mod(th,10)==0
disp([ 'ctRadon Theta: ', num2str(th), ' of ', num2str(numel(thetas)) ]);
end
end
end