Exemplo n.º 1
0
 def transform(self, I):
     I = ut.standardize_brightness(I)
     stain_matrix_source = get_stain_matrix(I)
     source_concentrations = ut.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)
Exemplo n.º 2
0
 def hematoxylin(self, I):
     I = ut.standardize_brightness(I)
     h, w, c = I.shape
     stain_matrix_source = get_stain_matrix(I)
     source_concentrations = ut.get_concentrations(I, stain_matrix_source)
     H = source_concentrations[:, 0].reshape(h, w)
     H = np.exp(-1 * H)
     return H
Exemplo n.º 3
0
 def transform(self, I):
     II = ut.standardize_brightness(I)
     I1, I2, I3 = lab_split(II)
     means, stds = get_mean_std(II)
     if stds[0] == 0 or stds[1] == 0 or stds[2] == 0:
         return I
     else:
         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 merge_back(norm1, norm2, norm3)
Exemplo n.º 4
0
 def fit(self, target):
     target = ut.standardize_brightness(target)
     means, stds = get_mean_std(target)
     self.target_means = means
     self.target_stds = stds
Exemplo n.º 5
0
 def fit(self, target):
     target = ut.standardize_brightness(target)
     self.stain_matrix_target = get_stain_matrix(target)