dask_image.ndmeasure 包

dask_image.ndmeasure 包

dask_image.ndmeasure.area(image, label_image=None, index=None)[来源]

找到图像中指定子区域的面积。

参数
  • image (ndarray) – N-D 图像数据

  • label_image (ndarray, 可选) – 用整数标记的图像特征。如果为 None(默认),则返回图像总尺寸的面积。

  • index (int 整数序列, 可选) – 输出中包含的标签。如果为 None(默认),则使用所有 label_image 非零的值。index 参数仅在指定 label_image 时有效。

返回

arealabel_imageindex 选定区域的面积。

返回类型

ndarray

示例

>>> 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)[来源]

找到图像中指定子区域的质心。

参数
  • image (ndarray) – N-D 图像数据

  • label_image (ndarray, 可选) – 用整数标记的图像特征。如果为 None(默认),则使用所有值。

  • index (int 整数序列, 可选) –

    输出中包含的标签。如果为 None(默认),则使用所有 label_image 非零的值。

    index 参数仅在指定 label_image 时有效。

返回

center_of_masslabel_imageindex 选定区域上 image 的质心坐标。

返回类型

ndarray

dask_image.ndmeasure.extrema(image, label_image=None, index=None)[来源]

找到图像中指定子区域的最小值、最大值及其位置。

参数
  • image (ndarray) – N-D 图像数据

  • label_image (ndarray, 可选) – 用整数标记的图像特征。如果为 None(默认),则使用所有值。

  • index (int 整数序列, 可选) –

    输出中包含的标签。如果为 None(默认),则使用所有 label_image 非零的值。

    index 参数仅在指定 label_image 时有效。

返回

minimums, maximums, min_positions, max_positions – 每个特征中的最小值和最大值及其坐标。

返回类型

ndarray 元组

dask_image.ndmeasure.histogram(image, min, max, bins, label_image=None, index=None)[来源]

找到图像中指定子区域的直方图。

直方图计算数组中在由 minmaxbins 确定的 bin 中的值的频率。label_imageindex 关键字可以将直方图的范围限制到数组中指定的子区域。

参数
  • image (ndarray) – N-D 图像数据

  • min (int) – 直方图 bin 范围的最小值。

  • max (int) – 直方图 bin 范围的最大值。

  • bins (int) – bin 的数量。

  • label_image (ndarray, 可选) – 用整数标记的图像特征。如果为 None(默认),则使用所有值。

  • index (int 整数序列, 可选) –

    输出中包含的标签。如果为 None(默认),则使用所有 label_image 非零的值。

    index 参数仅在指定 label_image 时有效。

返回

histogramlabel_imageindex 选定区域上 image 的直方图。

返回类型

ndarray

dask_image.ndmeasure.label(image, structure=None, wrap_axes=None)[来源]

标记数组中的特征。

参数
  • image (ndarray) – 要标记的类数组对象。image 中的任何非零值都被算作特征,零值被认为是背景。

  • structure (ndarray, 可选) –

    定义特征连接的结构元素。structure 必须是对称的。如果没有提供结构元素,则会自动生成一个连接度为一的方形结构元素。也就是说,对于一个 2-D image 数组,默认的结构元素是

    [[0,1,0],
     [1,1,1],
     [0,1,0]]
    

  • wrap_axes (int 元组, 可选) – 标签是否应跨越数组边界进行环绕,如果是,则指明哪些轴。此功能在 ndimage.label 中不存在。示例: - (0,) 仅沿第 0 轴环绕。 - (0, 1) 沿第 0 轴和第 1 轴环绕。 - (0, 1, 3) 沿第 0、第 1 和第 3 轴环绕。

返回

  • label (ndarray int) – 一个整数 ndarray,其中 image 中的每个独特特征在返回的数组中都有一个独特的标签。

  • num_features (int) – 找到了多少个对象。

dask_image.ndmeasure.labeled_comprehension(image, label_image, index, func, out_dtype, default, pass_positions=False)[来源]

在图像中指定子区域计算函数。

大致等同于 [func(image[labels == i]) for i in index]。

将任意函数(适用于类数组图像)按顺序应用于由 label_imageindex 指定的 n-D 图像数组子集。可以选择将位置参数作为第二个参数提供给函数。

参数
  • image (ndarray) – N-D 图像数据

  • label_image (ndarray, 可选) – 用整数标记的图像特征。如果为 None(默认),则使用所有值。

  • index (int 整数序列, 可选) –

    输出中包含的标签。如果为 None(默认),则使用所有 label_image 非零的值。

    index 参数仅在指定 label_image 时有效。

  • func (callable) – 要应用于 imagelabel_image 的 Python 函数。

  • out_dtype (dtype) – 用于 result 的 dtype。

  • default (int, float None) – 当 label_image 中不存在 index 的元素时的默认返回值。

  • pass_positions (bool, 可选) – 如果为 True,则将线性索引作为第二个参数传递给 func。默认为 False。

返回

result – 对 label_imageindex 选定区域上 image 应用 func 的结果。

返回类型

ndarray

dask_image.ndmeasure.maximum(image, label_image=None, index=None)[来源]

找到图像中指定子区域的最大值。

参数
  • image (ndarray) – N-D 图像数据

  • label_image (ndarray, 可选) – 用整数标记的图像特征。如果为 None(默认),则使用所有值。

  • index (int 整数序列, 可选) –

    输出中包含的标签。如果为 None(默认),则使用所有 label_image 非零的值。

    index 参数仅在指定 label_image 时有效。

返回

maximalabel_imageindex 选定区域上 image 的最大值。

返回类型

ndarray

dask_image.ndmeasure.maximum_position(image, label_image=None, index=None)[来源]

找到图像中指定子区域的最大值位置。

对于由 label_image 指定的每个区域,返回该区域内 image 最大值的位置。

参数
  • image (ndarray) – N-D 图像数据

  • label_image (ndarray, 可选) – 用整数标记的图像特征。如果为 None(默认),则使用所有值。

  • index (int 整数序列, 可选) –

    输出中包含的标签。如果为 None(默认),则使用所有 label_image 非零的值。

    index 参数仅在指定 label_image 时有效。

返回

maxima_positionslabel_imageindex 选定区域上 image 的最大值位置。

返回类型

ndarray

dask_image.ndmeasure.mean(image, label_image=None, index=None)[来源]

找到图像中指定子区域的平均值。

参数
  • image (ndarray) – N-D 图像数据

  • label_image (ndarray, 可选) – 用整数标记的图像特征。如果为 None(默认),则使用所有值。

  • index (int 整数序列, 可选) –

    输出中包含的标签。如果为 None(默认),则使用所有 label_image 非零的值。

    index 参数仅在指定 label_image 时有效。

返回

meanslabel_imageindex 选定区域上 image 的平均值。

返回类型

ndarray

dask_image.ndmeasure.median(image, label_image=None, index=None)[来源]

找到图像中指定子区域的中位数。

参数
  • image (ndarray) – N-D 图像数据

  • label_image (ndarray, 可选) – 用整数标记的图像特征。如果为 None(默认),则使用所有值。

  • index (int 整数序列, 可选) –

    输出中包含的标签。如果为 None(默认),则使用所有 label_image 非零的值。

    index 参数仅在指定 label_image 时有效。

返回

medianslabel_imageindex 选定区域上 image 的中位数。

返回类型

ndarray

dask_image.ndmeasure.minimum(image, label_image=None, index=None)[来源]

找到图像中指定子区域的最小值。

参数
  • image (ndarray) – N-D 图像数据

  • label_image (ndarray, 可选) – 用整数标记的图像特征。如果为 None(默认),则使用所有值。

  • index (int 整数序列, 可选) –

    输出中包含的标签。如果为 None(默认),则使用所有 label_image 非零的值。

    index 参数仅在指定 label_image 时有效。

返回

minimalabel_imageindex 选定区域上 image 的最小值。

返回类型

ndarray

dask_image.ndmeasure.minimum_position(image, label_image=None, index=None)[来源]

找到图像中指定子区域的最小值位置。

参数
  • image (ndarray) – N-D 图像数据

  • label_image (ndarray, 可选) – 用整数标记的图像特征。如果为 None(默认),则使用所有值。

  • index (int 整数序列, 可选) –

    输出中包含的标签。如果为 None(默认),则使用所有 label_image 非零的值。

    index 参数仅在指定 label_image 时有效。

返回

minima_positionslabel_imageindex 选定区域上 image 的最小值位置。

返回类型

ndarray

dask_image.ndmeasure.standard_deviation(image, label_image=None, index=None)[来源]

找到图像中指定子区域的标准差。

参数
  • image (ndarray) – N-D 图像数据

  • label_image (ndarray, 可选) – 用整数标记的图像特征。如果为 None(默认),则使用所有值。

  • index (int 整数序列, 可选) –

    输出中包含的标签。如果为 None(默认),则使用所有 label_image 非零的值。

    index 参数仅在指定 label_image 时有效。

返回

standard_deviationlabel_imageindex 选定区域上 image 的标准差。

返回类型

ndarray

dask_image.ndmeasure.sum(image, label_image=None, index=None)[来源]

已弃用函数。请改用 sum_labels

dask_image.ndmeasure.sum_labels(image, label_image=None, index=None)[来源]

找到图像中指定子区域的所有像素总和。

参数
  • image (ndarray) – N-D 图像数据

  • label_image (ndarray, 可选) – 用整数标记的图像特征。如果为 None(默认),则使用所有值。

  • index (int 整数序列, 可选) –

    输出中包含的标签。如果为 None(默认),则使用所有 label_image 非零的值。

    index 参数仅在指定 label_image 时有效。

返回

sum_lbllabel_imageindex 选定区域上 image 的总和。

返回类型

ndarray

dask_image.ndmeasure.variance(image, label_image=None, index=None)[来源]

找到图像中指定子区域的方差。

参数
  • image (ndarray) – N-D 图像数据

  • label_image (ndarray, 可选) – 用整数标记的图像特征。如果为 None(默认),则使用所有值。

  • index (int 整数序列, 可选) –

    输出中包含的标签。如果为 None(默认),则使用所有 label_image 非零的值。

    index 参数仅在指定 label_image 时有效。

返回

variancelabel_imageindex 选定区域上 image 的方差。

返回类型

ndarray