Exemplo n.º 1
0
 def split_labels(self, image):
     """
     Splits a groundtruth label image into a stack of one-hot encoded images.
     :param image: The groundtruth label image.
     :return: The one-hot encoded image.
     """
     split = split_label_image(np.squeeze(image, 0), list(range(8)),
                               np.uint8)
     split_smoothed = [
         gaussian(i, self.label_gaussian_sigma) for i in split
     ]
     smoothed = np.stack(split_smoothed, 0)
     image_smoothed = np.argmax(smoothed, axis=0)
     split = split_label_image(image_smoothed, list(range(8)), np.uint8)
     return np.stack(split, 0)
Exemplo n.º 2
0
 def binary_labels(self, image):
     """
     Converts an instance label image into a binary label. All instances will be set to 1.
     :param image: The instance label image.
     :return: A list of np arrays. First, is the background. Second is the foreground.
     """
     all_seg = ShiftScaleClamp(clamp_min=0, clamp_max=1)(image)
     return split_label_image(all_seg, [0, 1])
 def split_labels(self, image):
     """
     Splits a groundtruth label image into a stack of one-hot encoded images.
     :param image: The groundtruth label image.
     :return: The one-hot encoded image.
     """
     channel_axis = 0 if self.data_format == 'channels_first' else -1
     label_images = split_label_image(np.squeeze(image, channel_axis), [0] + self.landmark_labels, np.uint8)
     label_images_smoothed = smooth_label_images(label_images, sigma=self.label_gaussian_sigma)
     return np.stack(label_images_smoothed, channel_axis)
 def split_labels(self, image):
     """
     Splits a groundtruth label image into a stack of one-hot encoded images.
     :param image: The groundtruth label image.
     :return: The one-hot encoded image.
     """
     label_images = split_label_image(np.squeeze(image, 0),
                                      list(range(self.num_labels)),
                                      np.uint8)
     label_images_smoothed = smooth_label_images(
         label_images, sigma=self.label_gaussian_sigma)
     return np.stack(label_images_smoothed, 0)