candidates.py 文件源码

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

项目:kaggle_dsb 作者: syagev 项目源码 文件源码
def candidates_to_image(cands,radius):
    image_names = []
    for subset in xrange(0,10):
        subset_names = glob.glob("../data/subset{0}/*.mhd".format(subset))
        names = [os.path.split(x)[1].replace('.mhd','') for x in subset_names]
        image_names.append(names)
    previous_candidate = ""
    images = []
    image = []
    origin = []
    spacing = []
    number = 0
    for candidate in tqdm(cands.values):
        if candidate[0] != previous_candidate:
            number = 0
            previous_candidate = candidate[0]
            for image_subset in xrange(0,10):
                if candidate[0] in image_names[image_subset]:
                    image,origin,spacing = load_itk_image("../data/subset{0}/{1}.mhd".format(image_subset,candidate[0]))
                    break
        coords = world_2_voxel([candidate[3],candidate[2],candidate[1]],origin,spacing)
        im = image_part_from_candidate(image,coords,radius)
        #images.append(im)
        if candidate[4]:
            label = "true"
        else:
            label = "false"
        scipy.misc.imsave('../data/samples/{0}_{1}_{2}.jpg'.format(candidate[0],number,label), im)
        number += 1
    return images
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号