def __call__(self, **data_dict): seg = data_dict.get("seg") if seg is not None: new_seg = np.zeros([seg.shape[0], len(self.classes)] + list(seg.shape[2:]), dtype=seg.dtype) for b in range(seg.shape[0]): new_seg[b] = convert_seg_image_to_one_hot_encoding(seg[b, self.seg_channel], self.classes) data_dict[self.output_key] = new_seg else: from warnings import warn warn("calling ConvertSegToOnehotTransform but there is no segmentation") return data_dict
def __call__(self, **data_dict): seg = data_dict.get("seg") if seg is not None: new_seg = np.zeros([seg.shape[0], len(self.classes)] + list(seg.shape[2:]), dtype=seg.dtype) for b in range(seg.shape[0]): new_seg[b] = convert_seg_image_to_one_hot_encoding(seg[b, self.seg_channel], self.classes) data_dict[self.output_key] = new_seg else: from warnings import warn warn("calling ConvertSegToOnehotTransform but there is no segmentation") return data_dict
def __call__(self, **data_dict): seg = data_dict.get("seg") if seg is not None: new_seg = np.zeros([seg.shape[0], len(self.classes) * seg.shape[1]] + list(seg.shape[2:]), dtype=seg.dtype) for b in range(seg.shape[0]): for c in range(seg.shape[1]): new_seg[b, c*len(self.classes):(c+1)*len(self.classes)] = convert_seg_image_to_one_hot_encoding(seg[b, c], self.classes) data_dict["seg"] = new_seg else: from warnings import warn warn("calling ConvertMultiSegToOnehotTransform but there is no segmentation") return data_dict