dask_image.ndmeasure package¶
-
dask_image.ndmeasure.
area
(image, label_image=None, index=None)[source]¶ Find the area of specified subregions in an image.
- Parameters
image (ndarray) – N-D image data
label_image (ndarray, optional) – Image features noted by integers. If None (default), returns area of total image dimensions.
index (int or sequence of ints, optional) – Labels to include in output. If None (default), all values where non-zero
label_image
are used. Theindex
argument only works whenlabel_image
is specified.
- Returns
area – Area of
index
selected regions fromlabel_image
.- Return type
ndarray
Example
>>> import dask.array as da >>> image = da.random.random((3, 3)) >>> label_image = da.from_array( [[1, 1, 0], [1, 0, 3], [0, 7, 0]], chunks=(1, 3))
>>> # No labels given, returns area of total image dimensions >>> area(image) 9
>>> # Combined area of all non-zero labels >>> area(image, label_image).compute() 5
>>> # Areas of selected labels selected with the ``index`` keyword argument >>> area(image, label_image, index=[0, 1, 2, 3]).compute() array([4, 3, 0, 1], dtype=int64)
-
dask_image.ndmeasure.
center_of_mass
(image, label_image=None, index=None)[source]¶ Find the center of mass over an image at specified subregions.
- Parameters
image (ndarray) – N-D image data
label_image (ndarray, optional) – Image features noted by integers. If None (default), all values.
index (int or sequence of ints, optional) –
Labels to include in output. If None (default), all values where non-zero
label_image
are used.The
index
argument only works whenlabel_image
is specified.
- Returns
center_of_mass – Coordinates of centers-of-mass of
image
over theindex
selected regions fromlabel_image
.- Return type
ndarray
-
dask_image.ndmeasure.
extrema
(image, label_image=None, index=None)[source]¶ Find the min and max with positions over an image at specified subregions.
- Parameters
image (ndarray) – N-D image data
label_image (ndarray, optional) – Image features noted by integers. If None (default), all values.
index (int or sequence of ints, optional) –
Labels to include in output. If None (default), all values where non-zero
label_image
are used.The
index
argument only works whenlabel_image
is specified.
- Returns
minimums, maximums, min_positions, max_positions – Values and coordinates of minimums and maximums in each feature.
- Return type
tuple of ndarrays
-
dask_image.ndmeasure.
histogram
(image, min, max, bins, label_image=None, index=None)[source]¶ Find the histogram over an image at specified subregions.
Histogram calculates the frequency of values in an array within bins determined by
min
,max
, andbins
. Thelabel_image
andindex
keywords can limit the scope of the histogram to specified sub-regions within the array.- Parameters
image (ndarray) – N-D image data
min (int) – Minimum value of range of histogram bins.
max (int) – Maximum value of range of histogram bins.
bins (int) – Number of bins.
label_image (ndarray, optional) – Image features noted by integers. If None (default), all values.
index (int or sequence of ints, optional) –
Labels to include in output. If None (default), all values where non-zero
label_image
are used.The
index
argument only works whenlabel_image
is specified.
- Returns
histogram – Histogram of
image
over theindex
selected regions fromlabel_image
.- Return type
ndarray
-
dask_image.ndmeasure.
label
(image, structure=None)[source]¶ Label features in an array.
- Parameters
image (ndarray) – An array-like object to be labeled. Any non-zero values in
image
are counted as features and zero values are considered the background.structure (ndarray, optional) –
A structuring element that defines feature connections.
structure
must be symmetric. If no structuring element is provided, one is automatically generated with a squared connectivity equal to one. That is, for a 2-Dimage
array, the default structuring element is:[[0,1,0], [1,1,1], [0,1,0]]
- Returns
label (ndarray or int) – An integer ndarray where each unique feature in
image
has a unique label in the returned array.num_features (int) – How many objects were found.
-
dask_image.ndmeasure.
labeled_comprehension
(image, label_image, index, func, out_dtype, default, pass_positions=False)[source]¶ Compute a function over an image at specified subregions.
Roughly equivalent to [func(image[labels == i]) for i in index].
Sequentially applies an arbitrary function (that works on array_like image) to subsets of an n-D image array specified by
label_image
andindex
. The option exists to provide the function with positional parameters as the second argument.- Parameters
image (ndarray) – N-D image data
label_image (ndarray, optional) – Image features noted by integers. If None (default), all values.
index (int or sequence of ints, optional) –
Labels to include in output. If None (default), all values where non-zero
label_image
are used.The
index
argument only works whenlabel_image
is specified.func (callable) – Python function to apply to
label_image
fromimage
.out_dtype (dtype) – Dtype to use for
result
.default (int, float or None) – Default return value when a element of
index
does not exist inlabel_image
.pass_positions (bool, optional) – If True, pass linear indices to
func
as a second argument. Default is False.
- Returns
result – Result of applying
func
onimage
over theindex
selected regions fromlabel_image
.- Return type
ndarray
-
dask_image.ndmeasure.
maximum
(image, label_image=None, index=None)[source]¶ Find the maxima over an image at specified subregions.
- Parameters
image (ndarray) – N-D image data
label_image (ndarray, optional) – Image features noted by integers. If None (default), all values.
index (int or sequence of ints, optional) –
Labels to include in output. If None (default), all values where non-zero
label_image
are used.The
index
argument only works whenlabel_image
is specified.
- Returns
maxima – Maxima of
image
over theindex
selected regions fromlabel_image
.- Return type
ndarray
-
dask_image.ndmeasure.
maximum_position
(image, label_image=None, index=None)[source]¶ Find the positions of maxima over an image at specified subregions.
For each region specified by
label_image
, the position of the maximum value ofimage
within the region is returned.- Parameters
image (ndarray) – N-D image data
label_image (ndarray, optional) – Image features noted by integers. If None (default), all values.
index (int or sequence of ints, optional) –
Labels to include in output. If None (default), all values where non-zero
label_image
are used.The
index
argument only works whenlabel_image
is specified.
- Returns
maxima_positions – Maxima positions of
image
over theindex
selected regions fromlabel_image
.- Return type
ndarray
-
dask_image.ndmeasure.
mean
(image, label_image=None, index=None)[source]¶ Find the mean over an image at specified subregions.
- Parameters
image (ndarray) – N-D image data
label_image (ndarray, optional) – Image features noted by integers. If None (default), all values.
index (int or sequence of ints, optional) –
Labels to include in output. If None (default), all values where non-zero
label_image
are used.The
index
argument only works whenlabel_image
is specified.
- Returns
means – Mean of
image
over theindex
selected regions fromlabel_image
.- Return type
ndarray
-
dask_image.ndmeasure.
median
(image, label_image=None, index=None)[source]¶ Find the median over an image at specified subregions.
- Parameters
image (ndarray) – N-D image data
label_image (ndarray, optional) – Image features noted by integers. If None (default), all values.
index (int or sequence of ints, optional) –
Labels to include in output. If None (default), all values where non-zero
label_image
are used.The
index
argument only works whenlabel_image
is specified.
- Returns
medians – Median of
image
over theindex
selected regions fromlabel_image
.- Return type
ndarray
-
dask_image.ndmeasure.
minimum
(image, label_image=None, index=None)[source]¶ Find the minima over an image at specified subregions.
- Parameters
image (ndarray) – N-D image data
label_image (ndarray, optional) – Image features noted by integers. If None (default), all values.
index (int or sequence of ints, optional) –
Labels to include in output. If None (default), all values where non-zero
label_image
are used.The
index
argument only works whenlabel_image
is specified.
- Returns
minima – Minima of
image
over theindex
selected regions fromlabel_image
.- Return type
ndarray
-
dask_image.ndmeasure.
minimum_position
(image, label_image=None, index=None)[source]¶ Find the positions of minima over an image at specified subregions.
- Parameters
image (ndarray) – N-D image data
label_image (ndarray, optional) – Image features noted by integers. If None (default), all values.
index (int or sequence of ints, optional) –
Labels to include in output. If None (default), all values where non-zero
label_image
are used.The
index
argument only works whenlabel_image
is specified.
- Returns
minima_positions – Maxima positions of
image
over theindex
selected regions fromlabel_image
.- Return type
ndarray
-
dask_image.ndmeasure.
standard_deviation
(image, label_image=None, index=None)[source]¶ Find the standard deviation over an image at specified subregions.
- Parameters
image (ndarray) – N-D image data
label_image (ndarray, optional) – Image features noted by integers. If None (default), all values.
index (int or sequence of ints, optional) –
Labels to include in output. If None (default), all values where non-zero
label_image
are used.The
index
argument only works whenlabel_image
is specified.
- Returns
standard_deviation – Standard deviation of
image
over theindex
selected regions fromlabel_image
.- Return type
ndarray
-
dask_image.ndmeasure.
sum
(image, label_image=None, index=None)[source]¶ DEPRECATED FUNCTION. Use sum_labels instead.
-
dask_image.ndmeasure.
sum_labels
(image, label_image=None, index=None)[source]¶ Find the sum of all pixels over specified subregions of an image.
- Parameters
image (ndarray) – N-D image data
label_image (ndarray, optional) – Image features noted by integers. If None (default), all values.
index (int or sequence of ints, optional) –
Labels to include in output. If None (default), all values where non-zero
label_image
are used.The
index
argument only works whenlabel_image
is specified.
- Returns
sum_lbl – Sum of
image
over theindex
selected regions fromlabel_image
.- Return type
ndarray
-
dask_image.ndmeasure.
variance
(image, label_image=None, index=None)[source]¶ Find the variance over an image at specified subregions.
- Parameters
image (ndarray) – N-D image data
label_image (ndarray, optional) – Image features noted by integers. If None (default), all values.
index (int or sequence of ints, optional) –
Labels to include in output. If None (default), all values where non-zero
label_image
are used.The
index
argument only works whenlabel_image
is specified.
- Returns
variance – Variance of
image
over theindex
selected regions fromlabel_image
.- Return type
ndarray