segmentationdataset.py 文件源码

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

项目:SyConn 作者: StructuralNeurobiologyLab 项目源码 文件源码
def create_hull_voxels(self):
        voxels = np.copy(self.voxels)
        if len(voxels.shape) > 1:
            voxels_array = np.array(voxels, dtype=np.int)
            x_min = np.min(voxels_array[:, 0]) - 2
            x_max = np.max(voxels_array[:, 0]) + 2
            y_min = np.min(voxels_array[:, 1]) - 2
            y_max = np.max(voxels_array[:, 1]) + 2
            z_min = np.min(voxels_array[:, 2]) - 2
            z_max = np.max(voxels_array[:, 2]) + 2

            matrix = np.zeros((x_max-x_min, y_max-y_min, z_max-z_min),
                              dtype=np.uint8)

            lower_boarder = np.array([basics.negative_to_zero(x_min),
                                      basics.negative_to_zero(y_min),
                                      basics.negative_to_zero(z_min)],
                                     dtype=np.int)

            voxels = np.array(voxels, dtype=np.int) - lower_boarder
            matrix[voxels[:, 0], voxels[:, 1], voxels[:, 2]] = 1

            k = np.array([[[0, 0, 0], [0, 1, 0], [0, 0, 0]],
                          [[0, 1, 0], [1, 1, 1], [0, 1, 0]],
                          [[0, 0, 0], [0, 1, 0], [0, 0, 0]]])
            coords = np.argwhere((ndimage.convolve(matrix, k, mode="constant", cval=0.) < 7)*matrix == 1) + lower_boarder
        else:
            coords = voxels
        return coords
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号