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.
This commit is contained in:
Tony S Yu
2012-07-28 00:13:33 -04:00
parent 449f3e4cbf
commit b6045a8d5f
+11 -1
View File
@@ -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()