def provide(self, request):
    voxel_size = self.spec[self.raw].voxel_size
    shape = gp.Coordinate(((1,) + request[self.raw].roi.get_shape()))
    noise = np.abs(np.random.randn(*shape))
    smoothed_noise = gaussian_filter(noise, sigma=self.smoothness)
    seeds = np.zeros(shape, dtype=int)
    for i in range(self.n_objects):
        if (i == 0):
            num_points = 100
        else:
            num_points = self.points_per_skeleton
        points = np.stack([np.random.randint(0, shape[dim], num_points) for dim in range(3)], axis=1)
        tree = skelerator.Tree(points)
        skeleton = skelerator.Skeleton(tree, [1, 1, 1], 'linear', generate_graph=False)
        seeds = skeleton.draw(seeds, np.array([0, 0, 0]), (i + 1))
    seeds[(maximum_filter(seeds, size=4) != seeds)] = 0
    seeds_dt = (distance_transform_edt((seeds == 0)) + (5.0 * smoothed_noise))
    gt_data = (cwatershed(seeds_dt, seeds).astype(np.uint64)[0] - 1)
    labels = np.unique(gt_data)
    raw_data = np.zeros_like(gt_data, dtype=np.uint8)
    value = 0
    for label in labels:
        raw_data[(gt_data == label)] = value
        value += (255.0 / self.n_objects)
    spec = request[self.raw].copy()
    spec.voxel_size = (1, 1)
    raw = gp.Array(raw_data, spec)
    spec = request[self.gt].copy()
    spec.voxel_size = (1, 1)
    gt_crop = ((request[self.gt].roi - request[self.raw].roi.get_begin()) / voxel_size)
    gt_crop = gt_crop.to_slices()
    gt = gp.Array(gt_data[gt_crop], spec)
    batch = gp.Batch()
    batch[self.raw] = raw
    batch[self.gt] = gt
    return batch
def provide(self, request):
    voxel_size = self.spec[self.raw].voxel_size
    shape = gp.Coordinate(((1,) + request[self.raw].roi.get_shape()))
    noise = np.abs(np.random.randn(*shape))
    smoothed_noise = gaussian_filter(noise, sigma=self.smoothness)
    seeds = np.zeros(shape, dtype=int)
    for i in range(self.n_objects):
        if (i == 0):
            num_points = 100
        else:
            num_points = self.points_per_skeleton
        points = np.stack([np.random.randint(0, shape[dim], num_points) for dim in range(3)], axis=1)
        tree = skelerator.Tree(points)
        skeleton = skelerator.Skeleton(tree, [1, 1, 1], 'linear', generate_graph=False)
        seeds = skeleton.draw(seeds, np.array([0, 0, 0]), (i + 1))
    seeds[(maximum_filter(seeds, size=4) != seeds)] = 0
    seeds_dt = (distance_transform_edt((seeds == 0)) + (5.0 * smoothed_noise))
    gt_data = (cwatershed(seeds_dt, seeds).astype(np.uint64)[0] - 1)
    labels = np.unique(gt_data)
    raw_data = np.zeros_like(gt_data, dtype=np.uint8)
    value = 0
    for label in labels:
        raw_data[(gt_data == label)] = value
        value += (255.0 / self.n_objects)
    spec = request[self.raw].copy()
    spec.voxel_size = (1, 1)
    raw = gp.Array(raw_data, spec)
    spec = request[self.gt].copy()
    spec.voxel_size = (1, 1)
    gt_crop = ((request[self.gt].roi - request[self.raw].roi.get_begin()) / voxel_size)
    gt_crop = gt_crop.to_slices()
    gt = gp.Array(gt_data[gt_crop], spec)
    batch = gp.Batch()
    batch[self.raw] = raw
    batch[self.gt] = gt
    return batch