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)
예제 #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
예제 #3
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)
     maxC_source = np.percentile(source_concentrations, 99, axis=0).reshape((1, 2))
     maxC_target = np.percentile(self.target_concentrations, 99, axis=0).reshape((1, 2))
     source_concentrations *= (maxC_target / maxC_source)
     return (255 * np.exp(-1 * np.dot(source_concentrations, self.stain_matrix_target).reshape(I.shape))).astype(np.uint8)
예제 #4
0
 def fit(self, target):
     target = ut.standardize_brightness(target)
     self.stain_matrix_target = get_stain_matrix(target)
     self.target_concentrations = ut.get_concentrations(
         target, self.stain_matrix_target)