class skimage.viewer.plugins.Plugin(image_filter=None, height=0, width=400, useblit=True, dock='bottom') [source]
 
Bases: object Base class for plugins that interact with an ImageViewer. A plugin connects an image filter (or another function) to an image viewer. Note that a Plugin is initialized without an image viewer and attached in a later step. See example below for details.  Parameters 
 
image_viewerImageViewer 

Window containing image used in measurement/manipulation.  
image_filterfunction 

Function that gets called to update image in image viewer. This value can be None if, for example, you have a plugin that extracts information from an image and doesn’t manipulate it. Alternatively, this function can be defined as a method in a Plugin subclass.  
height, widthint 

Size of plugin window in pixels. Note that Qt will automatically resize a window to fit components. So if you’re adding rows of components, you can leave height = 0 and just let Qt determine the final height.  
useblitbool 

If True, use blitting to speed up animation. Only available on some Matplotlib backends. If None, set to True when using Agg backend. This only has an effect if you draw on top of an image viewer.     Examples >>> from skimage.viewer import ImageViewer
>>> from skimage.viewer.widgets import Slider
>>> from skimage import data
>>>
>>> plugin = Plugin(image_filter=lambda img,
...                 threshold: img > threshold) 
>>> plugin += Slider('threshold', 0, 255)       
>>>
>>> image = data.coins()
>>> viewer = ImageViewer(image)       
>>> viewer += plugin                  
>>> thresholded = viewer.show()[0][0] 
 The plugin will automatically delegate parameters to image_filter based on its parameter type, i.e., ptype (widgets for required arguments must be added in the order they appear in the function). The image attached to the viewer is automatically passed as the first argument to the filter function. #TODO: Add flag so image is not passed to filter function by default. ptype = ‘kwarg’ is the default for most widgets so it’s unnecessary here.  Attributes 
 
image_viewerImageViewer 

Window containing image used in measurement.  
namestr 

Name of plugin. This is displayed as the window title.  
artistlist 

List of Matplotlib artists and canvastools. Any artists created by the plugin should be added to this list so that it gets cleaned up on close.      
__init__(image_filter=None, height=0, width=400, useblit=True, dock='bottom') [source]
 
Initialize self. See help(type(self)) for accurate signature. 
  
add_widget(widget) [source]
 
Add widget to plugin. Alternatively, Plugin’s __add__ method is overloaded to add widgets: plugin += Widget(...)
 Widgets can adjust required or optional arguments of filter function or parameters for the plugin. This is specified by the Widget’s ptype. 
  
attach(image_viewer) [source]
 
Attach the plugin to an ImageViewer. Note that the ImageViewer will automatically call this method when the plugin is added to the ImageViewer. For example: viewer += Plugin(...)
 Also note that attach automatically calls the filter function so that the image matches the filtered value specified by attached widgets. 
  
clean_up() [source]

  
closeEvent(event) [source]
 
On close disconnect all artists and events from ImageViewer. Note that artists must be appended to self.artists. 
  
display_filtered_image(image) [source]
 
Display the filtered image on image viewer. If you don’t want to simply replace the displayed image with the filtered image (e.g., you want to display a transparent overlay), you can override this method. 
  
filter_image(*widget_arg) [source]
 
Call image_filter with widget args and kwargs Note: display_filtered_image is automatically called. 
  
property filtered_image  
Return filtered image. 
  
image_changed = None 
  
image_viewer = 'Plugin is not attached to ImageViewer' 
  
name = 'Plugin' 
  
output() [source]
 
Return the plugin’s representation and data.  Returns 
 
imagearray, same shape as self.image_viewer.image, or None 

The filtered image.  
dataNone 

Any data associated with the plugin.     Notes Derived classes should override this method to return a tuple containing an overlay of the same shape of the image, and a data object. Either of these is optional: return None if you don’t want to return a value. 
  
remove_image_artists() [source]
 
Remove artists that are connected to the image viewer. 
  
show(main_window=True) [source]
 
Show plugin. 
  
update_plugin(name, value) [source]
 
Update keyword parameters of the plugin itself. These parameters will typically be implemented as class properties so that they update the image or some other component.