Skip to content

Commit d7d9e2e

Browse files
committed
MAINT: use convolve instead of skimage for downscale
Alternative implementation to #862
1 parent eaaacbf commit d7d9e2e

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

WrightTools/data/_data.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -934,9 +934,11 @@ def _nd_decimate(arr, factor):
934934
if isinstance(factor, (int, type(None))):
935935
factor = [factor] * arr.ndim
936936
factor = [1 if f is None else f for f in factor]
937-
for axis, f in enumerate(factor):
938-
if arr.shape[axis] >= f:
939-
arr = decimate(arr, f, axis=axis)
937+
factor = [1 if s == 1 else f for s, f in zip(arr.shape, factor)]
938+
m = np.ones(factor)
939+
sl = tuple(slice(None, None, f) for f in factor)
940+
arr = np.ascontiguousarray(scipy.ndimage.convolve(arr, m)[sl])
941+
arr = arr / m.size
940942
return arr
941943

942944
for channel in self.channels:

0 commit comments

Comments
 (0)