-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathNormRadon.m
46 lines (44 loc) · 1.62 KB
/
NormRadon.m
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
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Perform normalized Radon transform
%
% To account for varying lengths of trajectories, the Radon
% transform of the data is divided by the Radon transform of
% a ones matrix. When an optional mask is used over the data,
% the ones matrix is also masked.
%
% radon_ones can be pre-calculated and provided to avoid repeat
% calculation when processing multiple data with the same mask.
%
% Arguments:
% data (matrix)
% theta (vector)
% radon_ones (matrix): will be calculated if not provided
% mask (matrix): multiplies data by mask and calculates radon_ones
% epsilon (scalar): Threshold below which radon_ones will be set
% to NaN, which suppresses short length trajectories. Default
% is 0.1, meaning trajectories < 10% of max length are ignored.
%
% Returns:
% radout.txfm (matrix): the normalized Radon transform
% radout.theta (vector)
% radout.rp (vector)
% radout.radon_ones (matrix): the normalizing constant
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function radout = NormRadon(data, theta, radon_ones, mask, epsilon)
if ~exist('epsilon', 'var')
epsilon = 0.1;
end
if exist('mask', 'var') && ~isempty(mask)
data = data .* mask;
radon_ones = radon(mask, theta);
radon_ones(radon_ones < epsilon*max(radon_ones(:))) = NaN;
elseif ~exist('radon_ones', 'var') || isempty(radon_ones)
radon_ones = radon(ones(size(data)), theta);
radon_ones(radon_ones < epsilon*max(radon_ones(:))) = NaN;
end
[txfm, rp] = radon(data, theta);
txfm = txfm ./ radon_ones;
radout.txfm = txfm;
radout.theta = theta;
radout.rp = rp;
radout.radon_ones = radon_ones;