def has_uniform_seed_margin(self, seed_margin=20.0):
"""Test if a subvolume has a margin of uniform label around its seed.
Parameters
----------
seed_margin : float, optional
The minimum acceptable margin of uniform target label around the seed
voxel (in nm, default 20.0).
Returns
-------
bool
True if the rectangular margin around the seed position is uniform.
"""
margin = np.ceil(np.reciprocal(np.array(CONFIG.volume.resolution),
dtype=np.float64) * seed_margin).astype(np.int64)
mask_target = self.label_mask
# If data is unlabeled, can not test so always succeed.
if mask_target is None:
return True
# Seed location in the mask accounting for offset of label from image.
ctr = self.seed - (np.asarray(self.image.shape) - np.asarray(mask_target.shape)) // 2
seed_fov = (ctr - margin, ctr + margin + 1)
seed_region = mask_target[seed_fov[0][0]:seed_fov[1][0],
seed_fov[0][1]:seed_fov[1][1],
seed_fov[0][2]:seed_fov[1][2]]
return np.all(seed_region)
评论列表
文章目录