You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
By default, the values of the downsampled arrays are cast to the same data type as the input. This behavior can be changed with the ``preserve_dtype`` keyword argument to ``multiscale``.
40
-
41
-
Generate a multiscale representation of an ``xarray.DataArray``:
42
-
43
-
44
-
```python
45
-
from xarray_multiscale import multiscale, windowed_mean
* Arrays that are not evenly divisible by the downsampling factors will be trimmed as needed. If this behavior is undesirable, consider padding your array appropriately prior to downsampling.
109
-
* For chunked arrays (e.g., dask arrays), the current implementation divides the input data into *contiguous* chunks. This means that attempting to use downsampling schemes based on sliding windowed smoothing will produce edge artifacts.
110
-
111
-
### Development
112
-
113
-
This project is developed using [`hatch`](https://hatch.pypa.io/latest/).
114
-
Run tests with `hatch run test:pytest`.
115
-
Serve docs with `hatch run docs:serve`.
39
+
read more in the [project documentation](https://JaneliaSciComp.github.io/xarray-multiscale/).
Copy file name to clipboardExpand all lines: docs/index.md
+32-1Lines changed: 32 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -10,7 +10,38 @@ Simple tools for creating multiscale representations of large images.
10
10
11
11
Many image processing applications benefit from representing images at multiple scales (also known as [image pyramids](https://en.wikipedia.org/wiki/Pyramid_(image_processing)). This package provides tools for generating lazy multiscale representations of N-dimensional data using [`xarray`](http://xarray.pydata.org/en/stable/) to ensure that the downsampled images have the correct coordinates.
12
12
13
-
Why are coordinates important for this application? Because a downsampled image is typically scaled and *translated* relative to the source image. Without a coordinate-aware representation of the data, the scaling and translation information is easily lost.
13
+
### Coordinates matter when you downsample images
14
+
15
+
It's obvious that downsampling an image applies a scaling transformation, i.e. downsampling increases the distance between image samples. This is the whole purpose of downsampling the image. But it is less obvious that most downsampling operations also apply a *translation transformation* -- downsampling an image (generally) shifts the origin of the output relative to the source.
16
+
17
+
In signal processing terms, image downsampling combines an image filtering step (blending local intensities) with a resampling step (sampling intensities at a set of positions in the signal). When you resample an image, you get to choose which points to resample on, and the best choice for most simple downsampling routines is to resample on points that are slightly translated relative to the original image. For simple windowed downsampling, this means that the first element of the downsampled image lies
18
+
at the center (i.e., the mean) of the coordinate values of the window.
19
+
20
+
We can illustrate this with some simple examples:
21
+
22
+
```
23
+
2x windowed downsampling, in one dimension:
24
+
25
+
source coordinates: | 0 | 1 |
26
+
downsampled coordinates: | 0.5 |
27
+
```
28
+
29
+
```
30
+
3x windowed downsampling, in two dimensions:
31
+
32
+
source coordinates: | (0,0) | (0,1) | (0,2) |
33
+
| (1,0) | (1,1) | (1,2) |
34
+
| (2,0) | (2,1) | (2,2) |
35
+
36
+
downsampled coordinates: | |
37
+
| (1,1) |
38
+
| |
39
+
40
+
```
41
+
42
+
Another way of thinking about this is that if you downsample an arbitrarily large image to a single value, then the only sensible place to localize that value is at the center of the image. Thus, incrementally downsampling slightly shifts the downsampled image toward that point.
43
+
44
+
Why should you care? If you work with images where the coordinates matter (for example, images recorded from scientific instruments), then you should care about keeping track of those coordinates. Tools like numpy or scikit-image make it very easy to ignore the coordinates of your image. These tools model images as simple arrays, and from the array perspective `data[0,0]` and `downsampled_data[0,0]` lie on the same position in space because they take the same array index. However, `downsampled_data[0,0]` is almost certainly shifted relative to `data[0,0]`. Coordinate-blind tools like `scikit-image` force your to track the coordinates on your own, which is a recipe for mistakes. This is the value of `xarray`. By explicitly modelling coordinates alongside data values, `xarray` ensures that you never lose track of where your data comes from, which is why `xarray-multiscale` uses it.
0 commit comments