用法:
skimage.measure.regionprops(label_image, intensity_image=None, cache=True, coordinates=None, *, extra_properties=None)
测量标记图像区域的属性。
- label_image:(M, N[, P]) 数组
标记的输入图像。值为 0 的标签将被忽略。
- intensity_image:(M, N[, P][, C]) ndarray,可选
与标记图像大小相同的强度(即输入)图像,以及可选的多通道数据的额外维度。目前,这个额外的通道维度(如果存在)必须是最后一个轴。默认为无。
- cache:布尔型,可选
确定是否缓存计算的属性。缓存属性的计算速度要快得多,而内存消耗会增加。
- coordinates:DEPRECATED
此参数已弃用,并将在 scikit-image 的未来版本中删除。
有关更多详细信息,请参阅坐标约定。
- extra_properties:可调用的迭代
添加不包含在 skimage 中的额外属性计算函数。属性的名称是从函数名称派生的,dtype 是通过在小样本上调用函数来推断的。如果额外属性的名称与现有属性的名称冲突,则额外属性将不可见并发出 UserWarning。属性计算函数必须将区域掩码作为其第一个参数。如果属性需要强度图像,它必须接受强度图像作为第二个参数。
- properties:RegionProperties列表
每个项目说明一个带标签的区域,并且可以使用下面列出的属性进行访问。
参数:
返回:
注意:
以下属性可以作为属性或键访问:
- 区域int
区域的像素数。
- area_bboxint
边界框的像素数。
- area_convexint
凸包图像的像素数,它是包围该区域的最小凸多边形。
- area_filledint
该区域的像素数将所有的洞都填满。说明image_filled的区域。
- axis_major_length浮点数
具有与区域相同的归一化第二中心矩的椭圆长轴的长度。
- axis_minor_length浮点数
具有与区域相同的归一化第二中心矩的椭圆短轴的长度。
- 盒子元组
边界框
(min_row, min_col, max_row, max_col)
。属于边界框的像素位于半开区间[min_row; max_row)
和[min_col; max_col)
中。- 质心数组
质心坐标元组
(row, col)
。- centroid_local数组
质心坐标元组
(row, col)
,相对于区域边界框。- centroid_weighted数组
用强度图像加权的质心坐标元组
(row, col)
。- centroid_weighted_local数组
质心坐标元组
(row, col)
,相对于区域边界框,用强度图像加权。- 坐标(N, 2) 数组
该区域的坐标列表
(row, col)
。- 偏心浮点数
与区域具有相同second-moments 的椭圆的偏心率。偏心率是焦距(焦点之间的距离)与长轴长度之比。该值在区间 [0, 1) 中。为 0 时,椭圆变为圆形。
- equivalent_diameter_area浮点数
与区域面积相同的圆的直径。
- euler_numberint
非零像素集合的欧拉特性。计算为连接组件数减去孔数(input.ndim 连通性)。在 3D 中,连接组件的数量加上孔的数量减去隧道的数量。
- 程度浮点数
区域中的像素与总边界框中的像素之比。计算为
area / (rows * cols)
- feret_diameter_max浮点数
最大 Feret 直径计算为区域凸包轮廓周围点之间的最长距离,由
find_contours
确定。 [5]- 图片(H, J) ndarray
与边界框大小相同的切片二值区域图像。
- image_convex(H, J) ndarray
与边界框大小相同的二进制凸包图像。
- image_filled(H, J) ndarray
具有与边界框相同大小的填充孔的二进制区域图像。
- image_intensityndarray
区域边界框内的图像。
- inertia_tensorndarray
围绕其质量旋转的区域的惯性张量。
- inertia_tensor_eigvals元组
惯性张量的特征值按降序排列。
- intensity_max浮点数
该地区强度最大的值。
- intensity_mean浮点数
该区域的平均强度值。
- intensity_min浮点数
该区域中强度最小的值。
- 标签int
带标签的输入图像中的标签。
- 时刻(3, 3) 数组
高达三阶的空间矩:
m_ij = sum{ array(row, col) * row^i * col^j }
其中总和在该区域的行、col 坐标上。
- moments_central(3, 3) 数组
最高 3 阶的中心矩(平移不变):
mu_ij = sum{ array(row, col) * (row - row_c)^i * (col - col_c)^j }
其中总和在行上,区域的 col 坐标,row_c 和 col_c 是区域质心的坐标。
- moments_hu元组
Hu 矩(平移、缩放和旋转不变)。
- moments_normalized(3, 3) 数组
归一化矩(平移和尺度不变)高达 3 阶:
nu_ij = mu_ij / m_00^[(i+j)/2 + 1]
其中 m_00 是第零个空间矩。
- moments_weighted(3, 3) 数组
高达 3 阶的强度图像的空间矩:
wm_ij = sum{ array(row, col) * row^i * col^j }
其中总和在该区域的行、col 坐标上。
- moments_weighted_central(3, 3) 数组
高达 3 阶的强度图像的中心矩(平移不变):
wmu_ij = sum{ array(row, col) * (row - row_c)^i * (col - col_c)^j }
其中总和在行上,区域的 col 坐标,row_c 和 col_c 是区域加权质心的坐标。
- moments_weighted_hu元组
强度图像的 Hu 矩(平移、缩放和旋转不变)。
- moments_weighted_normalized(3, 3) 数组
高达 3 阶的强度图像的归一化矩(平移和尺度不变):
wnu_ij = wmu_ij / wm_00^[(i+j)/2 + 1]
其中
wm_00
是第零空间矩(intensity-weighted区域)。- 方向浮点数
第 0 轴(行)与具有与该区域相同的秒矩的椭圆长轴之间的角度,逆时针范围从 -pi/2 到 pi/2。
- 周长浮点数
使用 4 连接将轮廓近似为通过边界像素中心的线的对象周长。
- perimeter_crofton浮点数
由 Crofton 公式在 4 个方向上近似的物体周长。
- 片切片元组
从源图像中提取对象的切片。
- 坚固性浮点数
区域中的像素与凸包图像的像素之比。
每个区域还支持迭代,这样你就可以做到:
for prop in region: print(prop, region[prop])
参考:
- 1
Wilhelm Burger, Mark Burge. Principles of Digital Image Processing: Core Algorithms. Springer-Verlag, London, 2009.
- 2
B. Jähne. Digital Image Processing. Springer-Verlag, Berlin-Heidelberg, 6. edition, 2005.
- 3
T. H. Reiss. Recognizing Planar Objects Using Invariant Image Features, from Lecture notes in computer science, p. 676. Springer, Berlin, 1993.
- 4
- 5
W. Pabst, E. Gregorová. Characterization of particles and particle systems, pp. 27-28. ICT Prague, 2007. https://old.vscht.cz/sil/keramika/Characterization_of_particles/CPPS%20_English%20version_.pdf
例子:
>>> from skimage import data, util >>> from skimage.measure import label, regionprops >>> img = util.img_as_ubyte(data.coins()) > 110 >>> label_img = label(img, connectivity=img.ndim) >>> props = regionprops(label_img) >>> # centroid of first labeled object >>> props[0].centroid (22.72987986048314, 81.91228523446583) >>> # centroid of first labeled object >>> props[0]['centroid'] (22.72987986048314, 81.91228523446583)
通过将函数传递为
extra_properties
添加自定义测量>>> from skimage import data, util >>> from skimage.measure import label, regionprops >>> import numpy as np >>> img = util.img_as_ubyte(data.coins()) > 110 >>> label_img = label(img, connectivity=img.ndim) >>> def pixelcount(regionmask): ... return np.sum(regionmask) >>> props = regionprops(label_img, extra_properties=(pixelcount,)) >>> props[0].pixelcount 7741 >>> props[1]['pixelcount'] 42
相关用法
- Python skimage.measure.regionprops_table用法及代码示例
- Python skimage.measure.ransac用法及代码示例
- Python skimage.measure.profile_line用法及代码示例
- Python skimage.measure.perimeter_crofton用法及代码示例
- Python skimage.measure.moments_hu用法及代码示例
- Python skimage.measure.moments_coords_central用法及代码示例
- Python skimage.measure.LineModelND用法及代码示例
- Python skimage.measure.block_reduce用法及代码示例
- Python skimage.measure.moments用法及代码示例
- Python skimage.measure.shannon_entropy用法及代码示例
- Python skimage.measure.moments_normalized用法及代码示例
- Python skimage.measure.euler_number用法及代码示例
- Python skimage.measure.perimeter用法及代码示例
- Python skimage.measure.moments_central用法及代码示例
- Python skimage.measure.EllipseModel用法及代码示例
- Python skimage.measure.find_contours用法及代码示例
- Python skimage.measure.CircleModel用法及代码示例
- Python skimage.measure.label用法及代码示例
- Python skimage.measure.moments_coords用法及代码示例
- Python skimage.metrics.hausdorff_distance用法及代码示例
注:本文由纯净天空筛选整理自scikit-image.org大神的英文原创作品 skimage.measure.regionprops。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。