python中的已连接组件属性 [英] connected components attributes in python

查看:166
本文介绍了python中的已连接组件属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想计算二进制映像的已连接组件的统计信息.在matlab中,我们有

I want to compute statistics on the connected components of a binary image. In matlab we have

形状测量

    'Area'              'EulerNumber'       'Orientation'               
    'BoundingBox'       'Extent'            'Perimeter'          
    'Centroid'          'Extrema'           'PixelIdxList' 
    'ConvexArea'        'FilledArea'        'PixelList'
    'ConvexHull'        'FilledImage'       'Solidity' 
    'ConvexImage'       'Image'             'SubarrayIdx'            
    'Eccentricity'      'MajorAxisLength' 
    'EquivDiameter'     'MinorAxisLength' 

python中是否有任何等效项?

Is there any equivalent in python?

谢谢

推荐答案

只需回答 regionprops 函数在scikit-image中获取Python的CC属性.

Just answered a similar question. Use the regionprops function in scikit-image to get the CC properties in Python.

from scipy.ndimage.measurements import label
from skimage.measure import regionprops
label = label(img)
props = regionprops(label)
# get centroid of second object
centroid = props[1].centroid
# get eccentricity of first object
ecc = props[0].eccentricity

regionprops输出的形状测量值包括问题中上面列出的所有功能. Python中的'PixelIdxList'等效项是regionprops输出的coords属性.

The shape measurements output by regionprops include all the features listed above in the question. The 'PixelIdxList' equivalent in Python is the coords property output by regionprops.

这篇关于python中的已连接组件属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆