From fcf45036711c97c51b62f65e3ae5cba930b655bb Mon Sep 17 00:00:00 2001 From: Luke Campagnola Date: Mon, 2 Oct 2017 08:58:03 -0700 Subject: [PATCH] Fix: avoid division by 0 when image is single valued --- pyqtgraph/functions.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pyqtgraph/functions.py b/pyqtgraph/functions.py index 1aed6ace..3a50eb9e 100644 --- a/pyqtgraph/functions.py +++ b/pyqtgraph/functions.py @@ -1079,7 +1079,9 @@ def makeARGB(data, lut=None, levels=None, scale=None, useRGBA=False): minVal, maxVal = levels[i] if minVal == maxVal: 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 else: # Apply level scaling unless it would have no effect on the data