コード例 #1
0
    def __get_oriented_image(self, cell, image_stack):
        x0 = int(round(cell.x - (self.rescaled_cube_width / 2)))
        x1 = int(x0 + self.rescaled_cube_width)
        y0 = int(round(cell.y - (self.rescaled_cube_height / 2)))
        y1 = int(y0 + self.rescaled_cube_height)
        image = image_stack[:, y0:y1, x0:x1]
        image = np.moveaxis(image, 0, 2)

        if self.augment:
            # scale to isotropic, but don't scale back
            image = augment(self.augmentation_parameters,
                            image,
                            scale_back=False)

        pixel_scalings = [
            self.cube_height / image.shape[0],
            self.cube_width / image.shape[1],
            self.cube_depth / image.shape[2],
        ]

        # TODO: ensure this is always the correct size
        image = zoom(image, pixel_scalings, order=self.interpolation_order)
        return image
コード例 #2
0
 def __get_oriented_image(self, image_path):
     # if paths are pathlib objs, skimage only reads one plane
     image = np.moveaxis(imread(image_path), 0, 2)
     if self.augment:
         image = augment(self.augmentation_parameters, image)
     return image