Skip to content

Commit 401514e

Browse files
Merge pull request #41 from ajinkya-kulkarni/patch-3
Improve code readability and speed
2 parents db43d62 + 706bea1 commit 401514e

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

torchstain/numpy/normalizers/reinhard.py

+7-3
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,9 @@ def fit(self, target):
2525
lab = rgb2lab(target)
2626

2727
# get summary statistics
28-
stack_ = np.array([get_mean_std(x) for x in lab_split(lab)])
28+
# stack_ = np.apply_along_axis(get_mean_std, 1, lab_split(lab))
29+
stack_ = np.apply_along_axis(get_mean_std, axis=1, arr=lab_split(lab))
30+
2931
self.target_means = stack_[:, 0]
3032
self.target_stds = stack_[:, 1]
3133

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

4042
# get summary statistics from LAB
41-
stack_ = np.array([get_mean_std(x) for x in labs])
43+
# stack_ = np.apply_along_axis(get_mean_std, 1, labs)
44+
stack_ = np.apply_along_axis(get_mean_std, axis=1, arr=labs)
45+
4246
mus = stack_[:, 0]
4347
stds = stack_[:, 1]
4448

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

6367
else:
6468
raise ValueError("Unsupported 'method' was chosen. Choose either {None, 'modified'}.")
65-
69+
6670
# rebuild LAB
6771
lab = lab_merge(*result)
6872

0 commit comments

Comments
 (0)