Skip to content

Commit b0a0ccd

Browse files
author
jklebes
committed
undo previous type problems, correct my understandng of stripe tolerance
1 parent c6c1321 commit b0a0ccd

File tree

2 files changed

+13
-18
lines changed

2 files changed

+13
-18
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ equivlently
2626

2727
``stripeFilter = 'Gaussian' `` or ``'hard'`` - stripe filter mode, default ``'gaussian'``
2828

29-
``stripeWidth`` - stripe width to suppress, default ``3``. If ``0``, no stripe supression will take place, even if ``stripeOption = 'Horizontal' `` or ``'Vertical'`` was chosen.
29+
``stripeTolerance`` - tolerance (in percent) for stripe deviation from horizontal/vertical alignement, default ``5``.
3030

3131
``filter='gaussian', 'butterworth'`` or ``'hard'``, filter profile, default ``'gaussian'``
3232

imbandpass.m

+12-17
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
%stripe Filter option
2121
addParameter(p,'stripeFilter', 'gaussian', @(x) any(validatestring(x,{'gaussian', 'hard'})));
2222
%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))
2424
%filter type, default gaussian
2525
addParameter(p,'filter', 'gaussian', @(x) any(validatestring(x,{'gaussian','butterworth', 'hard'})))
2626
addParameter(p,'butterworthN', 1)
@@ -45,11 +45,6 @@
4545
high_cutoff=maxdim*100;
4646
%and e^(-infty)=0 hopefuly
4747
end
48-
if p.Results.stripeWidth<=0
49-
stripes='None';
50-
else
51-
stripes=p.Results.stripes;
52-
end
5348

5449
%save image size
5550
image_size=size(image);
@@ -89,41 +84,41 @@
8984
switch p.Results.stripeFilter
9085
case "hard"
9186
%add a stripe of 0s to the mask
92-
switch stripes
87+
switch p.Results.stripes
9388
case 'Horizontal'
9489
%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)
9791
mask(:,col)=0;
9892
end
9993
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)
10295
mask(row,:)=0;
10396
end
10497
end
10598
case "gaussian"
10699
%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
108103
case 'Horizontal'
109104
%Fourier space stripe goes other way than in real space!
110105
xs= -(masksize_x/2):masksize_x/2-1;
111106
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));
113108
stripeMask=exp(-stripe_cutoff_ratio^2*xs.^2);
114109
mask=mask.*stripeMask;
115110
case 'Vertical'
116111
ys= -(masksize_y/2):masksize_y/2-1;
117112
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));
119114
stripeMask=exp(-stripe_cutoff_ratio^2*ys.^2);
120115
mask=mask.*stripeMask;
121-
%otherwise no stripe filtering action
116+
%otherwise no stripe filtering action
122117
end
123118

124119
end
125120
%apply mask
126-
fourier_masked = fourier_shifted .* mask;
121+
fourier_masked = fourier_shifted.* mask;
127122

128123
%center
129124
fourier_masked = fftshift(fourier_masked);
@@ -212,5 +207,5 @@
212207
end
213208
%else if argument is nonexistent, empty, or invalid option:
214209
%image stays unpadded
215-
image_out = uint8(round(fft2(image)));
210+
image_out = fft2(image);
216211
end

0 commit comments

Comments
 (0)