preprocessing.py 文件源码

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

项目:segmentation_DLMI 作者: imatge-upc 项目源码 文件源码
def compute_centralvoxel_frequencies(segment,minlength):
    if isinstance(segment,list):
        segment = np.asarray(segment)
    shape = segment.shape[-3:]

    middle_coordinate = np.zeros(3,int)
    for it_coordinate,coordinate in enumerate(shape):
        if coordinate%2==0:
            middle_coordinate[it_coordinate] = coordinate / 2 - 1
        else:
            middle_coordinate[it_coordinate] = coordinate/2

    segment = segment.reshape((-1,) + shape)
    f = 1.0 * np.bincount(segment[:,middle_coordinate[0],middle_coordinate[1],middle_coordinate[2]].reshape(-1,).astype(int),minlength=minlength) / np.prod(segment.shape[:-3])
    return f
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号