From bd2330af9f4c38d7f50818f797d95ce874a318f0 Mon Sep 17 00:00:00 2001 From: Luke Campagnola Date: Sun, 24 Nov 2013 20:45:10 -0500 Subject: [PATCH] ImageItem performance boost by avoiding makeQImage(transpose=True) --- pyqtgraph/functions.py | 3 +++ pyqtgraph/graphicsItems/ImageItem.py | 4 ++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/pyqtgraph/functions.py b/pyqtgraph/functions.py index b1934d0a..2930b0e7 100644 --- a/pyqtgraph/functions.py +++ b/pyqtgraph/functions.py @@ -875,6 +875,9 @@ def makeARGB(data, lut=None, levels=None, scale=None, useRGBA=False): order = [2,1,0,3] ## for some reason, the colors line up as BGR in the final image. if data.ndim == 2: + # This is tempting: + # imgData[..., :3] = data[..., np.newaxis] + # ..but it turns out this is faster: for i in range(3): imgData[..., i] = data elif data.shape[2] == 1: diff --git a/pyqtgraph/graphicsItems/ImageItem.py b/pyqtgraph/graphicsItems/ImageItem.py index 530db7fb..82807982 100644 --- a/pyqtgraph/graphicsItems/ImageItem.py +++ b/pyqtgraph/graphicsItems/ImageItem.py @@ -260,8 +260,8 @@ class ImageItem(GraphicsObject): #print lut.shape #print self.lut - argb, alpha = fn.makeARGB(self.image, lut=lut, levels=self.levels) - self.qimage = fn.makeQImage(argb, alpha) + argb, alpha = fn.makeARGB(self.image.T, lut=lut, levels=self.levels) + self.qimage = fn.makeQImage(argb, alpha, transpose=False) prof.finish()