|
4 | 4 | % Filtering operator is implemented by both convolution and FFT versions.
|
5 | 5 | function [pdOut, pdFlt] = filtering(pdIn, param)
|
6 | 6 |
|
7 |
| -pdOut = zeros(param.nDctX, param.nView); |
| 7 | +pdOut = zeros(param.nDctX, param.nView, 'like', pdIn); |
8 | 8 |
|
9 | 9 | % Filter is generated based on Ch.3 Equation (3.29)
|
10 | 10 | pdFlt = generate_filter(param.dDctX, param.nDctX);
|
|
14 | 14 | % Ch.3 Equation (3.30)
|
15 | 15 | % CONVOLUTION ver.
|
16 | 16 | for iview = 0:param.nView-1
|
17 |
| -% pdFltY(:, iview+1) = convolution1d(pdY(:, iview+1), pdFlt, param.nDctX); |
| 17 | +% pdOut(:, iview+1) = convolution1d(pdIn(:, iview+1), pdFlt, param.nDctX); |
18 | 18 | pdOut(:, iview+1) = conv(pdIn(:, iview+1), pdFlt, 'same');
|
19 | 19 | end
|
20 | 20 |
|
21 | 21 | case 'fft'
|
22 | 22 | % Ch.3 Equation (3.21)
|
23 | 23 | % FFT ver.
|
24 |
| - pdOut_ = zeros(param.nDctX, 1); |
25 |
| - |
26 | 24 | nFlt = length(pdFlt);
|
27 |
| - pdFlt_ = pdFlt; |
28 |
| - pdFlt_(nFlt) = 0; |
29 |
| - pdFlt_ = fft(pdFlt_); |
| 25 | + |
| 26 | + len = 2^(ceil(log2(2*param.nDctX))); |
| 27 | + pdFlt(len) = 0; |
| 28 | + pdFlt_ = fft(pdFlt); |
30 | 29 |
|
31 | 30 | for iview = 0:param.nView-1
|
32 |
| - pdOut_(:) = 0; |
33 | 31 |
|
34 | 32 | pdIn_ = pdIn(:, iview+1);
|
35 |
| - pdIn_(nFlt) = 0; |
| 33 | + pdIn_(len) = 0; |
36 | 34 | pdIn_ = fft(pdIn_);
|
37 | 35 |
|
38 |
| - for iflt = 0:nFlt-1 |
39 |
| - pdOut_(iflt+1) = pdFlt_(iflt+1)*pdIn_(iflt+1); |
40 |
| - end |
| 36 | + pdOut_ = pdFlt_.*pdIn_; |
41 | 37 |
|
42 | 38 | pdOut_ = ifft(pdOut_, 'symmetric');
|
43 |
| - pdOut(:, iview+1) = pdOut_(nFlt - param.nDctX + 1: nFlt); |
| 39 | +% pdOut(:, iview+1) = pdOut_(nFlt - param.nDctX + 1: nFlt); |
| 40 | + pdOut(:, iview+1) = pdOut_(param.nDctX:2*param.nDctX - 1); |
44 | 41 | end
|
45 | 42 | end
|
46 | 43 |
|
|
0 commit comments