unet_d8g_222f.py 文件源码

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

项目:kaggle_dsb2017 作者: astoc 项目源码 文件源码
def draw_circles(image,cands,origin,spacing):
    #make empty matrix, which will be filled with the mask
    image_mask = np.zeros(image.shape, dtype=np.int16)

    #run over all the nodules in the lungs
    for ca in cands.values:
        #get middel x-,y-, and z-worldcoordinate of the nodule
        #radius = np.ceil(ca[4])/2     ## original:  replaced the ceil with a very minor increase of 1% ....
        radius = (ca[4])/2 + 0.51 * spacing[0]  # increasing by circa half of distance in z direction .... (trying to capture wider region/border for learning ... and adress the rough net .

        coord_x = ca[1]
        coord_y = ca[2]
        coord_z = ca[3]
        image_coord = np.array((coord_z,coord_y,coord_x))

        #determine voxel coordinate given the worldcoordinate
        image_coord = world_2_voxel(image_coord,origin,spacing)

        #determine the range of the nodule
        #noduleRange = seq(-radius, radius, RESIZE_SPACING[0])  # original, uniform spacing 
        noduleRange_z = seq(-radius, radius, spacing[0])
        noduleRange_y = seq(-radius, radius, spacing[1])
        noduleRange_x = seq(-radius, radius, spacing[2])

          #x = y = z = -2
        #create the mask
        for x in noduleRange_x:
            for y in noduleRange_y:
                for z in noduleRange_z:
                    coords = world_2_voxel(np.array((coord_z+z,coord_y+y,coord_x+x)),origin,spacing)
                    #if (np.linalg.norm(image_coord-coords) * RESIZE_SPACING[0]) < radius:  ### original (contrained to a uniofrm RESIZE)
                    if (np.linalg.norm((image_coord-coords) * spacing)) < radius:
                        image_mask[int(np.round(coords[0])),int(np.round(coords[1])),int(np.round(coords[2]))] = int(1)


    return image_mask
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号