From 4405942256ecc704983254bffd7f50e29a3127db Mon Sep 17 00:00:00 2001 From: Laurent Claustre Date: Tue, 3 Dec 2019 10:08:37 +0100 Subject: [PATCH] fixed valid min/max before scaling --- plugins/Bpm.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/plugins/Bpm.py b/plugins/Bpm.py index 1fa8ae3..0798e04 100644 --- a/plugins/Bpm.py +++ b/plugins/Bpm.py @@ -659,7 +659,6 @@ def construct_bvdata(bpm): if not bpm.autoscale: min_val = bpm.min_max[0] max_val = bpm.min_max[1] - if max_val == 0: max_val = 1 scale_image = image.buffer.clip(min_val, max_val) # auto scaling: use natural image intensity @@ -668,6 +667,7 @@ def construct_bvdata(bpm): max_val = image.buffer.max() if max_val == 0: max_val = 1 scale_image = image.buffer + # logarithmic scaling if bpm.lut_method=="LOG": @@ -677,9 +677,10 @@ def construct_bvdata(bpm): scale_image = numpy.log10(scale_image.clip(1, None)) min_val += 1 min_val = numpy.log10(min_val) - max_val = numpy.log10(max_val if max_val > 0 else 1) + max_val = numpy.log10(max_val) # scale the image to the whole range 16bit before palette transformation for 0 to 65535 + if max_val == min_val: max_val+=1 scaling = (2**16 - 1.) / (max_val - min_val) scale_image = ((scale_image - min_val) * scaling).astype(numpy.uint16)