Skip to content

Commit

Permalink
MAINT: use convolve instead of skimage for downscale
Browse files Browse the repository at this point in the history
Alternative implementation to #862
  • Loading branch information
ksunden committed Jan 16, 2019
1 parent eaaacbf commit d7d9e2e
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions WrightTools/data/_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -934,9 +934,11 @@ def _nd_decimate(arr, factor):
if isinstance(factor, (int, type(None))):
factor = [factor] * arr.ndim
factor = [1 if f is None else f for f in factor]
for axis, f in enumerate(factor):
if arr.shape[axis] >= f:
arr = decimate(arr, f, axis=axis)
factor = [1 if s == 1 else f for s, f in zip(arr.shape, factor)]
m = np.ones(factor)
sl = tuple(slice(None, None, f) for f in factor)
arr = np.ascontiguousarray(scipy.ndimage.convolve(arr, m)[sl])
arr = arr / m.size
return arr

for channel in self.channels:
Expand Down

0 comments on commit d7d9e2e

Please sign in to comment.