Gracefully handle case where image data has size==0

This commit is contained in:
Luke Campagnola 2018-04-25 16:11:25 -07:00
parent 888ed6d55f
commit 0c1cda4973
2 changed files with 7 additions and 3 deletions

View File

@ -465,11 +465,11 @@ class ImageItem(GraphicsObject):
This method is also used when automatically computing levels.
"""
if self.image is None:
if self.image is None or self.image.size == 0:
return None,None
if step == 'auto':
step = (int(np.ceil(self.image.shape[0] / targetImageSize)),
int(np.ceil(self.image.shape[1] / targetImageSize)))
step = (max(1, int(np.ceil(self.image.shape[0] / targetImageSize))),
max(1, int(np.ceil(self.image.shape[1] / targetImageSize))))
if np.isscalar(step):
step = (step, step)
stepData = self.image[::step[0], ::step[1]]

View File

@ -633,8 +633,12 @@ class ImageView(QtGui.QWidget):
cax = self.axes['c']
if cax is None:
if data.size == 0:
return [(0, 0)]
return [(float(nanmin(data)), float(nanmax(data)))]
else:
if data.size == 0:
return [(0, 0)] * data.shape[-1]
return [(float(nanmin(data.take(i, axis=cax))),
float(nanmax(data.take(i, axis=cax)))) for i in range(data.shape[-1])]