could ndmeasure functions with index parameters take arrays?
- Dominant language
- Python
- Stars
- 226
- Forks
- 56
- PR merge metrics
- No merged PRs in 30d
Description
* dask-image version: 0.2.0
* Python version: 3.6
* Operating System: Ubuntu 18.04
### Description
I often want to label an array using `dask_image`, and then measure something about all the labels (except background). The measurement functions take a parameter `index` which is a list of labels, but the number of labels found is returned as a (delayed) dask array.
I understand the number of labels is global -- am I out of luck in avoiding `nlabels.compute()` below? At the very least, it would be nice to avoid directly doing that, even if it is done under the hood during execution.
Even nicer would be the functionality to just specify "all labels" or "all labels except 0", which I think are common cases. Does that seem reasonable?
### What I Did
```
arr = da.from_array([
[0, 0, 0, 1, 1],
[0, 0, 0, 0, 0],
[1, 1, 0, 1, 1],
[1, 1, 0, 1, 1],
])
labels, nlabels = ndmeasure.label(arr)
ndmeasure.center_of_mass(arr, labels, range(1, nlabels+1))
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
in
6 ])
7 labels, nlabels = ndmeasure.label(arr)
----> 8 ndmeasure.center_of_mass(arr, labels, range(1, nlabels+1))
TypeError: 'Array' object cannot be interpreted as an integer
```
Contributor guide
Assessment
This issue has not been assessed yet.