Skip to content

Commit 229d8bd

Browse files
committed
merge from upstream
2 parents c646e28 + e792790 commit 229d8bd

File tree

7 files changed

+477
-1099
lines changed

7 files changed

+477
-1099
lines changed

README.rst

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@ Many image processing applications benefit from representing images at multiple
1616

1717
Implementation
1818
**************
19-
At the moment, this package generates an image pyramid by using the ``dask.array.coarsen`` (`docs <https://docs.dask.org/en/latest/array-api.html#dask.array.coarsen>`_) to apply a reducing function to contiguous, non-overlapping chunks of the input data. With this implementation, it is not possible to generate a "Gaussian" image pyramid (i.e., a sequence of images that are recursively smoothed with a Gaussian filter and then resampled) because this exceeds the capabilities of ``dask.array.coarsen``. Gaussian pyramid support might be added in the future.
19+
The top-level function `multiscale` takes two main arguments: data to be downscaled, and a reduction function. The reduction function can use any implementation but it should (eagerly) take array data and a tuple of scale factors as inputs and return downscaled data as an output. See examples of reduction functions in `xarray_multiscale.reducers <https://github.com/JaneliaSciComp/xarray-multiscale/blob/main/src/xarray_multiscale/reducers.py>`_.
20+
21+
Note that the current implementation divides the input data into *contiguous* chunks. This means that attempting to use downscaling schemes based on sliding windowed smoothing will produce edge artifacts. Future versions of this package could enable applying the reduction function to *overlapping* chunks, which would enable more elaborate downscaling routines.
2022

2123

2224
Usage
@@ -27,10 +29,10 @@ Generate a lazy multiscale representation of a numpy array:
2729
.. code-block:: python
2830
2931
from xarray_multiscale import multiscale
30-
import numpy as np
32+
from xarray_multiscale.reducers import windowed_mean
3133
3234
data = np.arange(4)
33-
multiscale(data, np.mean, (2,))
35+
multiscale(data, windowed_mean, (2,))
3436
3537
which returns this (a collection of DataArrays, each with decreasing size):
3638

@@ -53,15 +55,15 @@ Generate a lazy multiscale representation of an ``xarray.DataArray``:
5355
.. code-block:: python
5456
5557
from xarray_multiscale import multiscale
56-
import numpy as np
58+
from xarray_multiscale.reducers import windowed_mean
5759
from xarray import DataArray
5860
5961
data = np.arange(16).reshape((4,4))
6062
coords = (DataArray(np.arange(data.shape[0]), dims=('y',), attrs={'units' : 'm'}),
6163
DataArray(np.arange(data.shape[0]), dims=('x',), attrs={'units' : 'm'}))
6264
6365
dataarray = DataArray(data, coords)
64-
multiscale(dataarray, np.mean, (2,2))
66+
multiscale(dataarray, windowed_mean, (2,2))
6567
6668
which returns this:
6769

0 commit comments

Comments
 (0)