From c3e52f15b0df0104455922512762887fdfc81e25 Mon Sep 17 00:00:00 2001 From: Luke Campagnola Date: Tue, 3 Oct 2017 08:16:36 -0700 Subject: [PATCH] Fix ImageItem rgb histogram calculation --- pyqtgraph/graphicsItems/ImageItem.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/pyqtgraph/graphicsItems/ImageItem.py b/pyqtgraph/graphicsItems/ImageItem.py index 2ae8b812..34150282 100644 --- a/pyqtgraph/graphicsItems/ImageItem.py +++ b/pyqtgraph/graphicsItems/ImageItem.py @@ -489,14 +489,17 @@ class ImageItem(GraphicsObject): bins = [mn, mx] kwds['bins'] = bins - stepData = stepData[np.isfinite(stepData)] + if perChannel: hist = [] for i in range(stepData.shape[-1]): - h = np.histogram(stepData[..., i], **kwds) + stepChan = stepData[..., i] + stepChan = stepChan[np.isfinite(stepChan)] + h = np.histogram(stepChan, **kwds) hist.append((h[1][:-1], h[0])) return hist else: + stepData = stepData[np.isfinite(stepData)] hist = np.histogram(stepData, **kwds) return hist[1][:-1], hist[0]