From d98a92a603eced6c14373f8df62a56163d719fab Mon Sep 17 00:00:00 2001 From: Tony S Yu Date: Tue, 4 Sep 2012 23:04:32 -0400 Subject: [PATCH] ENH: Set viewer min-intensity to zero when possible. Some image dtypes allow negative values, but these are typically not used. If an dtype allows negative values, but no negative values are present in the image, set the minimum value to 0 so that the image doesn't look washed out. --- skimage/viewer/viewers/core.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/skimage/viewer/viewers/core.py b/skimage/viewer/viewers/core.py index 7c4b4753..490ff92c 100644 --- a/skimage/viewer/viewers/core.py +++ b/skimage/viewer/viewers/core.py @@ -144,6 +144,8 @@ class ImageViewer(QMainWindow): self._img = image self._image_plot.set_array(image) clim = dtype_range[image.dtype.type] + if clim[0] < 0 and image.min() >= 0: + clim = (0, clim[1]) self._image_plot.set_clim(clim) self.redraw()