Fix: avoid division by 0 when image is single valued
This commit is contained in:
parent
6e22524ac2
commit
fcf4503671
|
@ -1079,7 +1079,9 @@ def makeARGB(data, lut=None, levels=None, scale=None, useRGBA=False):
|
||||||
minVal, maxVal = levels[i]
|
minVal, maxVal = levels[i]
|
||||||
if minVal == maxVal:
|
if minVal == maxVal:
|
||||||
maxVal += 1e-16
|
maxVal += 1e-16
|
||||||
newData[...,i] = rescaleData(data[...,i], scale/(maxVal-minVal), minVal, dtype=dtype)
|
rng = maxVal-minVal
|
||||||
|
rng = 1 if rng == 0 else rng
|
||||||
|
newData[...,i] = rescaleData(data[...,i], scale / rng, minVal, dtype=dtype)
|
||||||
data = newData
|
data = newData
|
||||||
else:
|
else:
|
||||||
# Apply level scaling unless it would have no effect on the data
|
# Apply level scaling unless it would have no effect on the data
|
||||||
|
|
Loading…
Reference in New Issue
Block a user