diff --git a/pyqtgraph/functions.py b/pyqtgraph/functions.py index 8ce2c404..2c11b647 100644 --- a/pyqtgraph/functions.py +++ b/pyqtgraph/functions.py @@ -1074,7 +1074,7 @@ def makeARGB(data, lut=None, levels=None, scale=None, useRGBA=False): # Decide on maximum scaled value if scale is None: if lut is not None: - scale = lut.shape[0] - 1 + scale = lut.shape[0] else: scale = 255. diff --git a/pyqtgraph/tests/test_functions.py b/pyqtgraph/tests/test_functions.py index 68f3dc24..e013fe42 100644 --- a/pyqtgraph/tests/test_functions.py +++ b/pyqtgraph/tests/test_functions.py @@ -206,15 +206,15 @@ def test_makeARGB(): # lut smaller than maxint lut = np.arange(128).astype(np.uint8) im2, alpha = pg.makeARGB(im1, lut=lut) - checkImage(im2, np.linspace(0, 127, 256).astype('ubyte'), alpha, False) + checkImage(im2, np.linspace(0, 127.5, 256, dtype='ubyte'), alpha, False) # lut + levels lut = np.arange(256)[::-1].astype(np.uint8) im2, alpha = pg.makeARGB(im1, lut=lut, levels=[-128, 384]) - checkImage(im2, np.linspace(192, 65.5, 256).astype('ubyte'), alpha, False) + checkImage(im2, np.linspace(191.5, 64.5, 256, dtype='ubyte'), alpha, False) im2, alpha = pg.makeARGB(im1, lut=lut, levels=[64, 192]) - checkImage(im2, np.clip(np.linspace(385.5, -126.5, 256), 0, 255).astype('ubyte'), alpha, False) + checkImage(im2, np.clip(np.linspace(384.5, -127.5, 256), 0, 255).astype('ubyte'), alpha, False) # uint8 data + uint16 LUT lut = np.arange(4096)[::-1].astype(np.uint16) // 16