Merge pull request #675 from campagnola/fix-empty-image
Gracefully handle case where image data has size==0
This commit is contained in:
commit
748ca554e4
@ -469,11 +469,11 @@ class ImageItem(GraphicsObject):
|
|||||||
|
|
||||||
This method is also used when automatically computing levels.
|
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
|
return None,None
|
||||||
if step == 'auto':
|
if step == 'auto':
|
||||||
step = (int(np.ceil(self.image.shape[0] / targetImageSize)),
|
step = (max(1, int(np.ceil(self.image.shape[0] / targetImageSize))),
|
||||||
int(np.ceil(self.image.shape[1] / targetImageSize)))
|
max(1, int(np.ceil(self.image.shape[1] / targetImageSize))))
|
||||||
if np.isscalar(step):
|
if np.isscalar(step):
|
||||||
step = (step, step)
|
step = (step, step)
|
||||||
stepData = self.image[::step[0], ::step[1]]
|
stepData = self.image[::step[0], ::step[1]]
|
||||||
|
@ -633,8 +633,12 @@ class ImageView(QtGui.QWidget):
|
|||||||
|
|
||||||
cax = self.axes['c']
|
cax = self.axes['c']
|
||||||
if cax is None:
|
if cax is None:
|
||||||
|
if data.size == 0:
|
||||||
|
return [(0, 0)]
|
||||||
return [(float(nanmin(data)), float(nanmax(data)))]
|
return [(float(nanmin(data)), float(nanmax(data)))]
|
||||||
else:
|
else:
|
||||||
|
if data.size == 0:
|
||||||
|
return [(0, 0)] * data.shape[-1]
|
||||||
return [(float(nanmin(data.take(i, axis=cax))),
|
return [(float(nanmin(data.take(i, axis=cax))),
|
||||||
float(nanmax(data.take(i, axis=cax)))) for i in range(data.shape[-1])]
|
float(nanmax(data.take(i, axis=cax)))) for i in range(data.shape[-1])]
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user