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;
评论列表
文章目录