|
20 | 20 | %stripe Filter option
|
21 | 21 | addParameter(p,'stripeFilter', 'gaussian', @(x) any(validatestring(x,{'gaussian', 'hard'})));
|
22 | 22 | %stripe supression width: less than image dimension, 0->None
|
23 |
| -addParameter(p,'stripeWidth', 3, @(x) isnumeric(x)) |
| 23 | +addParameter(p,'stripeTolerance', 5, @(x) isnumeric(x)) |
24 | 24 | %filter type, default gaussian
|
25 | 25 | addParameter(p,'filter', 'gaussian', @(x) any(validatestring(x,{'gaussian','butterworth', 'hard'})))
|
26 | 26 | addParameter(p,'butterworthN', 1)
|
|
45 | 45 | high_cutoff=maxdim*100;
|
46 | 46 | %and e^(-infty)=0 hopefuly
|
47 | 47 | end
|
48 |
| -if p.Results.stripeWidth<=0 |
49 |
| - stripes='None'; |
50 |
| -else |
51 |
| - stripes=p.Results.stripes; |
52 |
| -end |
53 | 48 |
|
54 | 49 | %save image size
|
55 | 50 | image_size=size(image);
|
|
89 | 84 | switch p.Results.stripeFilter
|
90 | 85 | case "hard"
|
91 | 86 | %add a stripe of 0s to the mask
|
92 |
| - switch stripes |
| 87 | + switch p.Results.stripes |
93 | 88 | case 'Horizontal'
|
94 | 89 | %Fourier space stripe goes other way than in real space!
|
95 |
| - width=p.Results.stripeWidth; |
96 |
| - for col = floor(center_coord_x-width/2):ceil(center_coord_x+width/2) |
| 90 | + for col = floor(center_coord_x-width/2):ceil(center_coord_x+p.Results.stripeTolerance/2) |
97 | 91 | mask(:,col)=0;
|
98 | 92 | end
|
99 | 93 | case 'Vertical'
|
100 |
| - width=p.Results.stripeWidth; |
101 |
| - for row = floor(center_coord_y-width/2):ceil(center_coord_y+width/2) |
| 94 | + for row = floor(center_coord_y-width/2):ceil(center_coord_y+p.Results.stripeToleranceh/2) |
102 | 95 | mask(row,:)=0;
|
103 | 96 | end
|
104 | 97 | end
|
105 | 98 | case "gaussian"
|
106 | 99 | %add a gaussian stripe filter to the mask
|
107 |
| - switch stripes |
| 100 | + %the stripe Filter has this Fourier space width |
| 101 | + stripeWidth=(100-p.Results.stripeTolerance)/100; |
| 102 | + switch p.Results.stripes |
108 | 103 | case 'Horizontal'
|
109 | 104 | %Fourier space stripe goes other way than in real space!
|
110 | 105 | xs= -(masksize_x/2):masksize_x/2-1;
|
111 | 106 | xs = repmat(xs, [masksize_y 1]);
|
112 |
| - stripe_cutoff_ratio = p.Results.stripeWidth/(2*image_size(1)); |
| 107 | + stripe_cutoff_ratio = stripeWidth/(2*image_size(1)); |
113 | 108 | stripeMask=exp(-stripe_cutoff_ratio^2*xs.^2);
|
114 | 109 | mask=mask.*stripeMask;
|
115 | 110 | case 'Vertical'
|
116 | 111 | ys= -(masksize_y/2):masksize_y/2-1;
|
117 | 112 | ys = repmat(ys', [1 masksize_x]);
|
118 |
| - stripe_cutoff_ratio = p.Results.stripeWidth/(2*image_size(2)); |
| 113 | + stripe_cutoff_ratio = stripeWidth/(2*image_size(2)); |
119 | 114 | stripeMask=exp(-stripe_cutoff_ratio^2*ys.^2);
|
120 | 115 | mask=mask.*stripeMask;
|
121 |
| - %otherwise no stripe filtering action |
| 116 | + %otherwise no stripe filtering action |
122 | 117 | end
|
123 | 118 |
|
124 | 119 | end
|
125 | 120 | %apply mask
|
126 |
| -fourier_masked = fourier_shifted .* mask; |
| 121 | +fourier_masked = fourier_shifted.* mask; |
127 | 122 |
|
128 | 123 | %center
|
129 | 124 | fourier_masked = fftshift(fourier_masked);
|
|
212 | 207 | end
|
213 | 208 | %else if argument is nonexistent, empty, or invalid option:
|
214 | 209 | %image stays unpadded
|
215 |
| -image_out = uint8(round(fft2(image))); |
| 210 | +image_out = fft2(image); |
216 | 211 | end
|
0 commit comments