Skip to content

Commit bb1f9c3

Browse files
committed
Simplify filter creation
1 parent 8611d6c commit bb1f9c3

File tree

1 file changed

+5
-8
lines changed

1 file changed

+5
-8
lines changed

imageprocessing.py

+5-8
Original file line numberDiff line numberDiff line change
@@ -863,21 +863,18 @@ def makeFourierFilter(image_or_imsize, mode, filtertype, filter_kwargs={},
863863
# Create spatial frequency or orientations map
864864
X = createFourierMaps(imsize, mode)
865865

866-
# Pre-allocate filter, including trailing dimension for each sub-filter
867-
filt = np.zeros( X.shape + (len(filter_kwargs),) )
866+
# Pre-allocate filter
867+
filt = np.zeros(X.shape)
868868

869869
# Loop through filter_kwargs
870-
for i, this_filter_kwargs in enumerate(filter_kwargs):
870+
for this_filter_kwargs in filter_kwargs:
871871
# If doing frequency, just make filter and allocate to array
872872
if mode == 'sf':
873-
filt[..., i] = filter_func(X, **this_filter_kwargs)
873+
filt += filter_func(X, **this_filter_kwargs)
874874
# If doing orientation, sum 3 filters to include +/- pi rad
875875
else:
876876
for offset in [-pi, 0, pi]:
877-
filt[..., i] += filter_func(X + offset, **this_filter_kwargs)
878-
879-
# Sum filters along last dimension to create composite
880-
filt = filt.sum(axis=-1)
877+
filt += filter_func(X + offset, **this_filter_kwargs)
881878

882879
# Invert if requested
883880
if invert:

0 commit comments

Comments
 (0)