viewer.plugins
¶skimage.viewer.plugins.CannyPlugin (*args, …) |
Canny filter plugin to show edges of an image. |
skimage.viewer.plugins.ColorHistogram ([max_pct]) |
|
skimage.viewer.plugins.Crop ([maxdist]) |
|
skimage.viewer.plugins.LabelPainter ([max_radius]) |
|
skimage.viewer.plugins.LineProfile ([…]) |
Plugin to compute interpolated intensity under a scan line on an image. |
skimage.viewer.plugins.Measure ([maxdist]) |
|
skimage.viewer.plugins.OverlayPlugin (**kwargs) |
Plugin for ImageViewer that displays an overlay on top of main image. |
skimage.viewer.plugins.PlotPlugin ([…]) |
Plugin for ImageViewer that contains a plot canvas. |
skimage.viewer.plugins.Plugin ([…]) |
Base class for plugins that interact with an ImageViewer. |
skimage.viewer.plugins.base |
Base class for Plugins that interact with ImageViewer. |
skimage.viewer.plugins.canny |
|
skimage.viewer.plugins.color_histogram |
|
skimage.viewer.plugins.crop |
|
skimage.viewer.plugins.labelplugin |
|
skimage.viewer.plugins.lineprofile |
|
skimage.viewer.plugins.measure |
|
skimage.viewer.plugins.overlayplugin |
|
skimage.viewer.plugins.plotplugin |
ColorHistogram
¶skimage.viewer.plugins.
ColorHistogram
(max_pct=0.99, **kwargs)[source]¶Bases: skimage.viewer.plugins.plotplugin.PlotPlugin
name
= 'Color Histogram'¶output
()[source]¶Return the image mask and the histogram data.
Returns: | mask : array of bool, same shape as image
data : dict
|
---|
LineProfile
¶skimage.viewer.plugins.
LineProfile
(maxdist=10, epsilon='deprecated', limits='image', **kwargs)[source]¶Bases: skimage.viewer.plugins.plotplugin.PlotPlugin
Plugin to compute interpolated intensity under a scan line on an image.
See PlotPlugin and Plugin classes for additional details.
Parameters: | maxdist : float
limits : tuple or {None, ‘image’, ‘dtype’}
|
---|
get_profiles
()[source]¶Return intensity profile of the selected line.
Returns: | end_points: (2, 2) array
profile: list of 1d arrays
|
---|
name
= 'Line Profile'¶output
()[source]¶Return the drawn line and the resulting scan.
Returns: | line_image : (M, N) uint8 array, same shape as image
scan : (P,) or (P, 3) array of int or float
|
---|
OverlayPlugin
¶skimage.viewer.plugins.
OverlayPlugin
(**kwargs)[source]¶Bases: skimage.viewer.plugins.base.Plugin
Plugin for ImageViewer that displays an overlay on top of main image.
The base Plugin class displays the filtered image directly on the viewer. OverlayPlugin will instead overlay an image with a transparent colormap.
See base Plugin class for additional details.
Attributes
overlay | (array) Overlay displayed on top of image. This overlay defaults to a color map with alpha values varying linearly from 0 to 1. |
color | (int) Color of overlay. |
color
¶colors
= {'cyan': (0, 1, 1), 'yellow': (1, 1, 0), 'red': (1, 0, 0), 'green': (0, 1, 0)}¶display_filtered_image
(image)[source]¶Display filtered image as an overlay on top of image in viewer.
filtered_image
¶Return filtered image.
This “filtered image” is used when saving from the plugin.
output
()[source]¶Return the overlaid image.
Returns: | overlay : array, same shape as image
data : None |
---|
overlay
¶PlotPlugin
¶skimage.viewer.plugins.
PlotPlugin
(image_filter=None, height=150, width=400, **kwargs)[source]¶Bases: skimage.viewer.plugins.base.Plugin
Plugin for ImageViewer that contains a plot canvas.
Base class for plugins that contain a Matplotlib plot canvas, which can, for example, display an image histogram.
See base Plugin class for additional details.
Plugin
¶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_viewer : ImageViewer
image_filter : function
height, width : int
useblit : bool
|
---|
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_viewer | (ImageViewer) Window containing image used in measurement. |
name | (str) Name of plugin. This is displayed as the window title. |
artist | (list) 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. |
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.
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.
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: | image : array, same shape as
data : None
|
---|
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.