diff --git a/skimage/viewer/plugins/base.py b/skimage/viewer/plugins/base.py index c5dd2770..9f5d25dc 100644 --- a/skimage/viewer/plugins/base.py +++ b/skimage/viewer/plugins/base.py @@ -165,6 +165,11 @@ class Plugin(QDialog): # If param is a widget, return its `val` attribute. return param if not hasattr(param, 'val') else param.val + @property + def filtered_image(self): + """Return filtered image.""" + return self.image_viewer.image + def display_filtered_image(self, image): """Display the filtered image on image viewer. diff --git a/skimage/viewer/plugins/overlayplugin.py b/skimage/viewer/plugins/overlayplugin.py index f9d37e59..b4307d34 100644 --- a/skimage/viewer/plugins/overlayplugin.py +++ b/skimage/viewer/plugins/overlayplugin.py @@ -74,6 +74,14 @@ class OverlayPlugin(Plugin): self._overlay_plot.set_cmap(self.cmap) self.image_viewer.redraw() + @property + def filtered_image(self): + """Return filtered image. + + This "filtered image" is used when saving from the plugin. + """ + return self.overlay + def display_filtered_image(self, image): """Display filtered image as an overlay on top of image in viewer.""" self.overlay = image diff --git a/skimage/viewer/widgets/history.py b/skimage/viewer/widgets/history.py index efc8a21c..43a940dc 100644 --- a/skimage/viewer/widgets/history.py +++ b/skimage/viewer/widgets/history.py @@ -6,6 +6,9 @@ try: except ImportError: print("Could not import PyQt4 -- skimage.viewer not available.") +import numpy as np + +import skimage from skimage import io from .core import BaseWidget @@ -84,7 +87,11 @@ class SaveButtons(BaseWidget): basename, ext = os.path.splitext(filename) if not ext: filename = '%s.%s' % (filename, self.default_format) - io.imsave(filename, self.plugin.image_viewer.image) + image = self.plugin.filtered_image + if image.dtype == np.bool: + #TODO: This check/conversion should probably be in `imsave`. + image = skimage.img_as_ubyte(image) + io.imsave(filename, image) def notify(msg):