def fit(self, target):
     """
     Fit to a target image
     :param target:
     :return:
     """
     target = mu.standardize_brightness(target)
     self.stain_matrix_target = self.get_stain_matrix(target)
示例#2
0
 def fit(self, target):
     """
     Fit to a target image
     :param target:
     :return:
     """
     target = mu.standardize_brightness(target)
     means, stds = self.get_mean_std(target)
     self.target_means = means
     self.target_stds = stds
示例#3
0
 def fit(self, I, standardize_brightness=True):
     """
     Fit the augmentor to an image I
     :param I:
     :return:
     """
     if standardize_brightness:
         I = mu.standardize_brightness(I)
     self.Ishape = I.shape
     self.not_white = mu.notwhite_mask(I).reshape(-1)
     self.stain_matrix, self.source_concentrations = self.fetcher.compute(I)
 def transform(self, I):
     """
     Transform an image
     :param I:
     :return:
     """
     I = mu.standardize_brightness(I)
     stain_matrix_source = self.get_stain_matrix(I)
     source_concentrations = self.get_concentrations(I, stain_matrix_source)
     return (255 * np.exp(-1 * np.dot(
         source_concentrations, self.stain_matrix_target).reshape(I.shape))
             ).astype(np.uint8)
 def hematoxylin(self, I):
     """
     Hematoxylin channel
     :param I:
     :return:
     """
     I = mu.standardize_brightness(I)
     h, w, c = I.shape
     stain_matrix_source = self.get_stain_matrix(I)
     source_concentrations = self.get_concentrations(I, stain_matrix_source)
     H = source_concentrations[:, 0].reshape(h, w)
     H = np.exp(-1 * H)
     return H
示例#6
0
 def transform(self, I):
     """
     Transform an image
     :param I:
     :return:
     """
     I = mu.standardize_brightness(I)
     I1, I2, I3 = self.lab_split(I)
     means, stds = self.get_mean_std(I)
     norm1 = ((I1 - means[0]) *
              (self.target_stds[0] / stds[0])) + self.target_means[0]
     norm2 = ((I2 - means[1]) *
              (self.target_stds[1] / stds[1])) + self.target_means[1]
     norm3 = ((I3 - means[2]) *
              (self.target_stds[2] / stds[2])) + self.target_means[2]
     return self.merge_back(norm1, norm2, norm3)