Skip to content

Commit

Permalink
Merge pull request #41 from ajinkya-kulkarni/patch-3
Browse files Browse the repository at this point in the history
Improve code readability and speed
  • Loading branch information
carloalbertobarbano authored Jan 8, 2025
2 parents db43d62 + 706bea1 commit 401514e
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions torchstain/numpy/normalizers/reinhard.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@ def fit(self, target):
lab = rgb2lab(target)

# get summary statistics
stack_ = np.array([get_mean_std(x) for x in lab_split(lab)])
# stack_ = np.apply_along_axis(get_mean_std, 1, lab_split(lab))
stack_ = np.apply_along_axis(get_mean_std, axis=1, arr=lab_split(lab))

self.target_means = stack_[:, 0]
self.target_stds = stack_[:, 1]

Expand All @@ -38,7 +40,9 @@ def normalize(self, I):
labs = lab_split(lab)

# get summary statistics from LAB
stack_ = np.array([get_mean_std(x) for x in labs])
# stack_ = np.apply_along_axis(get_mean_std, 1, labs)
stack_ = np.apply_along_axis(get_mean_std, axis=1, arr=labs)

mus = stack_[:, 0]
stds = stack_[:, 1]

Expand All @@ -62,7 +66,7 @@ def normalize(self, I):

else:
raise ValueError("Unsupported 'method' was chosen. Choose either {None, 'modified'}.")

# rebuild LAB
lab = lab_merge(*result)

Expand Down

0 comments on commit 401514e

Please sign in to comment.