volumes.py 文件源码

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

项目:diluvian 作者: aschampion 项目源码 文件源码
def __init__(self, volume, shape, label_margin=None):
            self.volume = volume
            self.shape = shape
            self.margin = np.floor_divide(self.shape, 2).astype(np.int64)
            if label_margin is None:
                label_margin = np.zeros(3, dtype=np.int64)
            self.label_margin = label_margin
            self.skip_blank_sections = True
            self.ctr_min = self.margin
            self.ctr_max = (np.array(self.volume.shape) - self.margin - 1).astype(np.int64)
            self.random = np.random.RandomState(CONFIG.random_seed)

            # If the volume has a mask channel, further limit ctr_min and
            # ctr_max to lie inside a margin in the AABB of the mask.
            if self.volume.mask_data is not None:
                mask_min, mask_max = self.volume.mask_bounds

                mask_min = self.volume.local_coord_to_world(mask_min)
                mask_max = self.volume.local_coord_to_world(mask_max)

                self.ctr_min = np.maximum(self.ctr_min, mask_min + self.label_margin)
                self.ctr_max = np.minimum(self.ctr_max, mask_max - self.label_margin - 1)

            if np.any(self.ctr_min >= self.ctr_max):
                raise ValueError('Cannot generate subvolume bounds: bounds ({}, {}) too small for shape ({})'.format(
                                 np.array_str(self.ctr_min), np.array_str(self.ctr_max), np.array_str(self.shape)))
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号