Skip to content

Commit

Permalink
fixed valid min/max before scaling
Browse files Browse the repository at this point in the history
  • Loading branch information
Laurent Claustre committed Dec 3, 2019
1 parent c7c43aa commit 4405942
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions plugins/Bpm.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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":
Expand All @@ -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)

Expand Down

0 comments on commit 4405942

Please sign in to comment.