Skip to content

Commit acc40da

Browse files
authored
Merge pull request #133 from DiamondLightSource/rescaleint_fix
avoid division by zero in rescale_to_int
2 parents 3057e4a + 73a3527 commit acc40da

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

httomolibgpu/misc/rescale.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,10 @@ def __rescale_to_int(
139139
input_min = (perc_range_min * (range_intensity) / 100) + min_value
140140
input_max = (perc_range_max * (range_intensity) / 100) + min_value
141141

142-
factor = (output_max - output_min) / (input_max - input_min)
142+
if (input_max - input_min) != 0.0:
143+
factor = (output_max - output_min) / (input_max - input_min)
144+
else:
145+
factor = 1.0
143146

144147
res = cp.empty(data.shape, dtype=output_dtype)
145148
rescale_kernel = cp.ElementwiseKernel(

0 commit comments

Comments
 (0)