def get_contour_portion(images,segb):
ns = images.shape[0];
nt = images.shape[1];
portion = np.zeros((ns,nt));
for s in range(ns):
for t in range(nt):
img = images[s,t,0];
seg = segb[nt*s+t,0];
if np.sum(seg)<10:
portion[s,t] = 0.0;
continue;
mask = cv2.dilate(seg,np.ones((7,7)))-seg>0;
z = img[mask];
x,y = np.where(mask);
lvinside = np.mean(img[seg>0]);
lvoutside = np.percentile(z,20);
ccut = lvinside * 0.3 + lvoutside * 0.7;
cnt_sh = get_contour_shape(x,y,z);
if cnt_sh is None:
portion[s,t] = 0.0;
else:
res = get_eff_portion(cnt_sh,ccut);
portion[s,t] = res;
return portion;
评论列表
文章目录