submit.py 文件源码

python
阅读 27 收藏 0 点赞 0 评论 0

项目:segmentation 作者: zengyu714 项目源码 文件源码
def localization(x, y):
    """Simple post-processing and get IVDs positons.

    Return:
        positons: calculated by `ndimage.measurements.center_of_mass`
        y:        after fill holes and remove small objects.
    """
    labels, nums = label(y, return_num=True)
    areas = np.array([prop.filled_area for prop in regionprops(labels)])
    assert nums >= 7,  'Fail in this test, should detect at least seven regions.'

    # Segment a joint region which should be separate (if any).
    while np.max(areas) > 10000:
        y = ndimage.binary_opening(y, structure=np.ones((3, 3, 3)))
        areas = np.array([prop.filled_area for prop in regionprops(label(y))])

    # Remove small objects.
    threshold = sorted(areas, reverse=True)[7]
    y = morphology.remove_small_objects(y, threshold + 1)

    # Fill holes.
    y = ndimage.binary_closing(y, structure=np.ones((3, 3, 3)))
    y = morphology.remove_small_holes(y, min_size=512, connectivity=3)

    positions = ndimage.measurements.center_of_mass(x, label(y), range(1, 8))
    return np.array(positions), y
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号