mirror of
https://github.com/wassname/scikit-image.git
synced 2026-07-02 04:59:25 +08:00
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:
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user