-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapplysincfilter.m
40 lines (33 loc) · 1.32 KB
/
applysincfilter.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
function filteredProjections = applysincfilter(projections)
%
% sinc(x) function has characteristics of a low pass filter.
% this idea is used here
% input:
% projections : an array with all the projections per column.
% output:
% filteredProjections: returns projections after applying the filter
%
% initialization
filteredProjections = zeros(size(projections));
projectionSize = size(projections, 1);
nbOfProjections = size(projections, 2);
a = 1;
wgts = -pi:(2*pi/projectionSize):pi-(2*pi)/projectionSize;
% creating mask to multiply with projection to filter
mask = abs(2/a*sin(a.*wgts./2))*( (sin(a.*wgts./2))/((a*wgts)./2) )^2;
% zero-frequency component to the center
shiftedMask = move0frqcomp2center(mask);
% iterating through each projection
for step = 1:nbOfProjections
% extracting a projection
aProj = projections(:, step);
% taking fourier transform to multiply the mask
freqProj = fouriertransform(aProj);
% filtering the projection
filteredProj = freqProj .*shiftedMask';
% taking inverse fourier transform and adding it in right spot
spatiProj = inversefouriertrans(filteredProj);
filteredProjections(:, step) = spatiProj;
end
% considering only the real part of the filtered projections
filteredProjections = real(filteredProjections);