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)
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
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)
def transform(self, I): I = ut.standardize_brightness(I) I1, I2, I3 = lab_split(I) means, stds = 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 merge_back(norm1, norm2, norm3)
def fit(self, target): target = ut.standardize_brightness(target) self.stain_matrix_target = get_stain_matrix(target)
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)
def fit(self, target): target = ut.standardize_brightness(target) means, stds = get_mean_std(target) self.target_means = means self.target_stds = stds