From 69f5e9d5fe9d6f07d44f7d1e63c5bac7e7f2939b Mon Sep 17 00:00:00 2001 From: Juan Nunez-Iglesias Date: Thu, 10 Apr 2014 12:11:45 +1000 Subject: [PATCH 1/7] Update viewer example to use plugin outputs --- doc/source/user_guide/viewer.txt | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/doc/source/user_guide/viewer.txt b/doc/source/user_guide/viewer.txt index da7f0c50..4cdde7db 100644 --- a/doc/source/user_guide/viewer.txt +++ b/doc/source/user_guide/viewer.txt @@ -32,7 +32,14 @@ let's see an example of how a pre-defined plugin is added to the viewer: viewer = ImageViewer(image) viewer += LineProfile(viewer) - viewer.show() + overlay, data = viewer.show()[0] + +The viewer's ``show`` method will return an overlay (of the same shape as the +input image) and data (possibly ``None``) for each attached plugin. In this +case, there is only one plugin, so we can directly name both. You can see the +plugin class's ``output`` method to see what will be returned. Here, +``overlay`` contains a drawing of the line (including its width), and ``data`` +contains the measured line profile. At the moment, there are not many plugins pre-defined, but there is a really simple interface for creating your own plugin. First, let us create a plugin to @@ -74,8 +81,10 @@ All that's left is to create an image viewer and add the plugin to that viewer. viewer = ImageViewer(image) viewer += denoise_plugin - viewer.show() + denoised = viewer.show()[0][0] +When we close the viewer, ``denoised`` will contain the filtered image for the +last used setting of ``weight``. .. image:: data/denoise_viewer_window.png .. image:: data/denoise_plugin_window.png From 9ef9045875d09d1ed324ceb398f9133ea0ddb2aa Mon Sep 17 00:00:00 2001 From: Juan Nunez-Iglesias Date: Thu, 10 Apr 2014 12:16:14 +1000 Subject: [PATCH 2/7] Update lineprofile examples to use returned output --- viewer_examples/plugins/lineprofile.py | 2 +- viewer_examples/plugins/lineprofile_rgb.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/viewer_examples/plugins/lineprofile.py b/viewer_examples/plugins/lineprofile.py index 2f1b2cdc..dd80e277 100644 --- a/viewer_examples/plugins/lineprofile.py +++ b/viewer_examples/plugins/lineprofile.py @@ -6,4 +6,4 @@ from skimage.viewer.plugins.lineprofile import LineProfile image = data.camera() viewer = ImageViewer(image) viewer += LineProfile() -viewer.show() +line, profile = viewer.show()[0] diff --git a/viewer_examples/plugins/lineprofile_rgb.py b/viewer_examples/plugins/lineprofile_rgb.py index 86b71d5d..b08f5a00 100644 --- a/viewer_examples/plugins/lineprofile_rgb.py +++ b/viewer_examples/plugins/lineprofile_rgb.py @@ -6,4 +6,4 @@ from skimage.viewer.plugins.lineprofile import LineProfile image = data.chelsea() viewer = ImageViewer(image) viewer += LineProfile() -viewer.show() +line, profiles = viewer.show()[0] From 17541e2cdc43d8ea26e870b72281c8ef3719423c Mon Sep 17 00:00:00 2001 From: Juan Nunez-Iglesias Date: Thu, 10 Apr 2014 12:19:23 +1000 Subject: [PATCH 3/7] Update plugin class doc example to use output --- skimage/viewer/plugins/base.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/skimage/viewer/plugins/base.py b/skimage/viewer/plugins/base.py index dd3aebb0..baded1cb 100644 --- a/skimage/viewer/plugins/base.py +++ b/skimage/viewer/plugins/base.py @@ -63,9 +63,9 @@ class Plugin(QtGui.QDialog): >>> plugin += Slider('threshold', 0, 255) # doctest: +SKIP >>> >>> image = data.coins() - >>> viewer = ImageViewer(image) # doctest: +SKIP - >>> viewer += plugin # doctest: +SKIP - >>> viewer.show() # doctest: +SKIP + >>> viewer = ImageViewer(image) # doctest: +SKIP + >>> viewer += plugin # doctest: +SKIP + >>> thresholded = viewer.show()[0][0] # doctest: +SKIP The plugin will automatically delegate parameters to `image_filter` based on its parameter type, i.e., `ptype` (widgets for required arguments must From f2699bd731760b9d938680a7c4ed5fc5874ce228 Mon Sep 17 00:00:00 2001 From: Juan Nunez-Iglesias Date: Mon, 21 Apr 2014 00:11:55 +0200 Subject: [PATCH 4/7] Update Canny examples --- viewer_examples/plugins/canny.py | 2 +- viewer_examples/plugins/canny_simple.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/viewer_examples/plugins/canny.py b/viewer_examples/plugins/canny.py index eaa33330..686034b2 100644 --- a/viewer_examples/plugins/canny.py +++ b/viewer_examples/plugins/canny.py @@ -6,4 +6,4 @@ from skimage.viewer.plugins.canny import CannyPlugin image = data.camera() viewer = ImageViewer(image) viewer += CannyPlugin() -viewer.show() +canny_edges = viewer.show()[0][0] diff --git a/viewer_examples/plugins/canny_simple.py b/viewer_examples/plugins/canny_simple.py index c26ca08d..641ca138 100644 --- a/viewer_examples/plugins/canny_simple.py +++ b/viewer_examples/plugins/canny_simple.py @@ -21,4 +21,4 @@ plugin += SaveButtons(name='Save overlay to:') # Finally, attach the plugin to an image viewer. viewer = ImageViewer(image) viewer += plugin -viewer.show() +canny_edges = viewer.show()[0][0] From 548423bb940a38c599ac3b82bf8a1207b5112646 Mon Sep 17 00:00:00 2001 From: Juan Nunez-Iglesias Date: Thu, 8 May 2014 16:24:50 +1000 Subject: [PATCH 5/7] Update variable name for RGB line profile --- viewer_examples/plugins/lineprofile_rgb.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/viewer_examples/plugins/lineprofile_rgb.py b/viewer_examples/plugins/lineprofile_rgb.py index b08f5a00..577933a1 100644 --- a/viewer_examples/plugins/lineprofile_rgb.py +++ b/viewer_examples/plugins/lineprofile_rgb.py @@ -6,4 +6,4 @@ from skimage.viewer.plugins.lineprofile import LineProfile image = data.chelsea() viewer = ImageViewer(image) viewer += LineProfile() -line, profiles = viewer.show()[0] +line, rgb_profiles = viewer.show()[0] From 3d2af717444ee80563f7eb00b4b957a6b43aee74 Mon Sep 17 00:00:00 2001 From: Juan Nunez-Iglesias Date: Thu, 8 May 2014 17:21:35 +1000 Subject: [PATCH 6/7] Update description of viewer output in docs --- doc/source/user_guide/viewer.txt | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/doc/source/user_guide/viewer.txt b/doc/source/user_guide/viewer.txt index 4cdde7db..73c4dc00 100644 --- a/doc/source/user_guide/viewer.txt +++ b/doc/source/user_guide/viewer.txt @@ -34,12 +34,16 @@ let's see an example of how a pre-defined plugin is added to the viewer: viewer += LineProfile(viewer) overlay, data = viewer.show()[0] -The viewer's ``show`` method will return an overlay (of the same shape as the -input image) and data (possibly ``None``) for each attached plugin. In this -case, there is only one plugin, so we can directly name both. You can see the -plugin class's ``output`` method to see what will be returned. Here, -``overlay`` contains a drawing of the line (including its width), and ``data`` -contains the measured line profile. +The viewer's ``show()`` method returns a list of tuples, one for each attached +plugin. Each tuple contains two elements: an overlay of the same shape as the +input image, and a data field (which may be ``None``). A plugin class documents +its return value in its ``output`` method. + +In this example, only one plugin is attached, so the list returned by ``show`` +will have length 1. We extract that single tuple and bind its ``overlay`` and +``data`` elements to individual variables. Here, ``overlay`` contains an image +of the line drawn on the viewer, and ``data`` contains the 1-dimensional +intensity profile along that line. At the moment, there are not many plugins pre-defined, but there is a really simple interface for creating your own plugin. First, let us create a plugin to @@ -83,8 +87,8 @@ All that's left is to create an image viewer and add the plugin to that viewer. viewer += denoise_plugin denoised = viewer.show()[0][0] -When we close the viewer, ``denoised`` will contain the filtered image for the -last used setting of ``weight``. +Here, we access only the overlay returned by the plugin, which contains the +filtered image for the last used setting of ``weight``. .. image:: data/denoise_viewer_window.png .. image:: data/denoise_plugin_window.png From 53de0db1649fda3b219bc03302a43d2b5eeda35f Mon Sep 17 00:00:00 2001 From: Juan Nunez-Iglesias Date: Thu, 8 May 2014 18:19:57 +1000 Subject: [PATCH 7/7] Very minor text change --- doc/source/user_guide/viewer.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/source/user_guide/viewer.txt b/doc/source/user_guide/viewer.txt index 73c4dc00..3145effd 100644 --- a/doc/source/user_guide/viewer.txt +++ b/doc/source/user_guide/viewer.txt @@ -40,7 +40,7 @@ input image, and a data field (which may be ``None``). A plugin class documents its return value in its ``output`` method. In this example, only one plugin is attached, so the list returned by ``show`` -will have length 1. We extract that single tuple and bind its ``overlay`` and +will have length 1. We extract the single tuple and bind its ``overlay`` and ``data`` elements to individual variables. Here, ``overlay`` contains an image of the line drawn on the viewer, and ``data`` contains the 1-dimensional intensity profile along that line.