utils.py 文件源码

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

项目:aapm_thoracic_challenge 作者: xf4j 项目源码 文件源码
def restore_labels(labels, roi, read_info):
    if roi == -1:
        # Pad first, then resize to original shape
        labels = np.pad(labels, ((0, 0), (CROP, CROP), (CROP, CROP)), 'constant')
        restored_labels = np.zeros(read_info['shape'], dtype=np.float32)
        for z in range(N_CLASSES):
            roi = resize((labels == z + 1).astype(np.float32), read_info['shape'], mode='constant')
            roi[roi >= 0.5] = 1
            roi[roi < 0.5] = 0
            roi = clean_contour(roi, is_prob=False)
            restored_labels[roi == 1] = z + 1
    else:
        labels = clean_contour(labels, is_prob=True)
        # Resize to extracted shape, then pad to original shape
        labels = resize(labels, read_info['extract_shape'], mode='constant')
        restored_labels = np.zeros(read_info['shape'], dtype=np.float32)
        extract = read_info['extract']
        restored_labels[extract[0][0] : extract[0][1], extract[1][0] : extract[1][1], extract[2][0] : extract[2][1]] = labels
    return restored_labels
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号