diff --git a/CHANGELOG b/CHANGELOG index b8130f2b..079a8bf6 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -66,6 +66,7 @@ pyqtgraph-0.9.9 [unreleased] - Fixed unicode support in Dock - Fixed PySide crash caused by emitting signal from GraphicsObject.itemChange - Fixed possible infinite loop from FiniteCache + - Allow images with NaN in ImageView pyqtgraph-0.9.8 2013-11-24 diff --git a/README.md b/README.md index bd54d4e2..9e198abd 100644 --- a/README.md +++ b/README.md @@ -28,6 +28,7 @@ Contributors * Thomas S. * Fabio Zadrozny * Mikhail Terekhov + * Pietro Zambelli Requirements ------------ diff --git a/pyqtgraph/imageview/ImageView.py b/pyqtgraph/imageview/ImageView.py index bf415bb3..c7c3206e 100644 --- a/pyqtgraph/imageview/ImageView.py +++ b/pyqtgraph/imageview/ImageView.py @@ -33,6 +33,11 @@ from .. import debug as debug from ..SignalProxy import SignalProxy +try: + from bottleneck import nanmin, nanmax +except ImportError: + from numpy import nanmin, nanmax + #try: #from .. import metaarray as metaarray #HAVE_METAARRAY = True @@ -526,7 +531,7 @@ class ImageView(QtGui.QWidget): sl = [slice(None)] * data.ndim sl[ax] = slice(None, None, 2) data = data[sl] - return data.min(), data.max() + return nanmin(data), nanmax(data) def normalize(self, image): """ diff --git a/pyqtgraph/imageview/tests/test_imageview.py b/pyqtgraph/imageview/tests/test_imageview.py new file mode 100644 index 00000000..2ca1712c --- /dev/null +++ b/pyqtgraph/imageview/tests/test_imageview.py @@ -0,0 +1,11 @@ +import pyqtgraph as pg +import numpy as np + +app = pg.mkQApp() + +def test_nan_image(): + img = np.ones((10,10)) + img[0,0] = np.nan + v = pg.image(img) + app.processEvents() + v.window().close()