tools.py 文件源码

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

项目:cancer 作者: yancz1989 项目源码 文件源码
def get_img_mask(scan, h, nodules, nth=-1, z=None):
    """
    h = spacing_z/spacing_xy
    nodules = list (x,y,z,r) of the nodule, in Voxel space
    specify nth or z. nth: the nth nodule
    """
    if z is None:
        z = int(nodules[nth][2]);
    img = normalize(scan[z,:,:]);
    res = np.zeros(img.shape);
    #draw nodules
    for xyzd in nodules:
        r = xyzd[3]/2.0;
        dz = np.abs((xyzd[2]-z)*h);
        if dz>=r:continue
        rlayer = np.sqrt(r**2-dz**2);
        if rlayer<3:continue
        #create contour at xyzd[0],xyzd[1] with radius rlayer
        rr,cc=draw.circle(xyzd[1],xyzd[0],rlayer)
        res[rr,cc] = 1;
    return img,res;
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号