From b6045a8d5f1adc00860ab55e40f4201dd0e27f63 Mon Sep 17 00:00:00 2001 From: Tony S Yu Date: Sat, 28 Jul 2012 00:13:33 -0400 Subject: [PATCH] BUG: Fix behavior when initial overlay limits are bad. Intensity limits are calculated by the initial input image. If this image has, for example, all black pixels, then subsequent overlays will remain all black because of the initialized limits. Set limits based on data type to fix this issue. --- skimage/viewer/plugins/overlayplugin.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/skimage/viewer/plugins/overlayplugin.py b/skimage/viewer/plugins/overlayplugin.py index dbf15e7d..11ca5ab5 100644 --- a/skimage/viewer/plugins/overlayplugin.py +++ b/skimage/viewer/plugins/overlayplugin.py @@ -1,7 +1,15 @@ +import numpy as np + +from skimage.util import dtype from .base import Plugin from ..utils import ClearColormap +#TODO: Maybe this bool definition should be moved to skimage.util.dtype. +dtype_range = dtype.dtype_range.copy() +dtype_range[np.bool_] = (False, True) + + class OverlayPlugin(Plugin): """Plugin for ImageViewer that displays an overlay on top of main image. @@ -47,7 +55,9 @@ class OverlayPlugin(Plugin): ax.images.remove(self._overlay_plot) self._overlay_plot = None elif self._overlay_plot is None: - self._overlay_plot = ax.imshow(image, cmap=self.cmap) + vmin, vmax = dtype_range[image.dtype.type] + self._overlay_plot = ax.imshow(image, cmap=self.cmap, + vmin=vmin, vmax=vmax) else: self._overlay_plot.set_array(image) self.image_viewer.redraw()