Add plugin return values for ImageViewer

The model supported is that plugins can return an overlay, some data,
or both. Each plugin therefore returns an `(overlay, data)` tuple in
which each element can be `None`.

To allow return values, the plugin need only override the `output`
method defined in the base Plugin class.

See discussions here:
https://groups.google.com/d/msg/scikit-image/0nkJM-WguXA/iqogBABa748J
and here:
https://github.com/scikit-image/scikit-image/pull/805
This commit is contained in:
Juan Nunez-Iglesias
2013-10-31 14:51:06 +11:00
parent cfeb040126
commit 7774a76eea
2 changed files with 18 additions and 0 deletions
+17
View File
@@ -235,3 +235,20 @@ class Plugin(QtGui.QDialog):
"""Remove artists that are connected to the image viewer."""
for a in self.artists:
a.remove()
def output(self):
"""Return the plugin's representation and data.
Parameters
----------
None
Returns
-------
overlay : array, same shape as ``self.image_viewer.image``, or None
The filtered image.
data : array, arbitrary shape and type, or None
Any data associated with the plugin.
"""
return (self.image_viewer.image, None)
+1
View File
@@ -228,6 +228,7 @@ class ImageViewer(QtGui.QMainWindow):
self._show()
if main_window:
utils.start_qtapp()
return [p.output() for p in self.plugins]
def redraw(self):
self.canvas.draw_idle()