Skip to content

Commit 67a3c83

Browse files
committed
trying rescale_to_int C function
1 parent 5e1c8c5 commit 67a3c83

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

httomolibgpu/misc/rescale.py

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@
3030

3131
from httomolibgpu.misc.supp_func import data_checker
3232

33+
from sofia.core.regularisers import rescale_to_int_C
34+
3335
__all__ = [
3436
"rescale_to_int",
3537
]
@@ -107,17 +109,18 @@ def rescale_to_int(
107109
else:
108110
factor = 1.0
109111

110-
res = xp.empty(data.shape, dtype=output_dtype)
111112
if xp.__name__ == "numpy":
112113
if input_max == pow(2, 32):
113114
input_max -= 1
114-
res = np.copy(data.astype(float))
115-
res[data.astype(float) < input_min] = int(input_min)
116-
res[data.astype(float) > input_max] = int(input_max)
117-
res -= input_min
118-
res *= factor
119-
res = output_dtype(res)
115+
res = rescale_to_int_C(data, input_min, input_max, factor)
116+
# res = np.copy(data.astype(float))
117+
# res[data.astype(float) < input_min] = int(input_min)
118+
# res[data.astype(float) > input_max] = int(input_max)
119+
# res -= input_min
120+
# res *= factor
121+
# res = output_dtype(res)
120122
else:
123+
res = xp.empty(data.shape, dtype=output_dtype)
121124
rescale_kernel = cp.ElementwiseKernel(
122125
"T x, raw T input_min, raw T input_max, raw T factor",
123126
"O out",

0 commit comments

Comments
 (0)