viewer.plugins
Module: 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. |
CannyPlugin
-
class skimage.viewer.plugins.CannyPlugin(*args, **kwargs)
[source] -
Bases:
skimage.viewer.plugins.overlayplugin.OverlayPlugin
Canny filter plugin to show edges of an image.
-
__init__(*args, **kwargs)
[source]
-
attach(image_viewer)
[source]
-
name = 'Canny Filter'
-
ColorHistogram
-
class skimage.viewer.plugins.ColorHistogram(max_pct=0.99, **kwargs)
[source] -
Bases:
skimage.viewer.plugins.plotplugin.PlotPlugin
-
__init__(max_pct=0.99, **kwargs)
[source]
-
ab_selected(extents)
[source]
-
attach(image_viewer)
[source]
-
help()
[source]
-
name = 'Color Histogram'
-
output()
[source] -
Return the image mask and the histogram data.
Returns: mask : array of bool, same shape as image
The selected pixels.
data : dict
The data describing the histogram and the selected region. The dictionary contains:
- ‘bins’ : array of float The bin boundaries for both
a
andb
channels. - ‘hist’ : 2D array of float The normalized histogram.
- ‘edges’ : tuple of array of float The bin edges along each dimension
- ‘extents’ : tuple of float The left and right and top and bottom of the selected region.
- ‘bins’ : array of float The bin boundaries for both
-
Crop
-
class skimage.viewer.plugins.Crop(maxdist=10, **kwargs)
[source] -
Bases:
skimage.viewer.plugins.base.Plugin
-
__init__(maxdist=10, **kwargs)
[source]
-
attach(image_viewer)
[source]
-
crop(extents)
[source]
-
help()
[source]
-
name = 'Crop'
-
reset()
[source]
-
LabelPainter
-
class skimage.viewer.plugins.LabelPainter(max_radius=20, **kwargs)
[source] -
Bases:
skimage.viewer.plugins.base.Plugin
-
__init__(max_radius=20, **kwargs)
[source]
-
attach(image_viewer)
[source]
-
help()
[source]
-
label
-
name = 'LabelPainter'
-
on_enter(overlay)
[source]
-
radius
-
LineProfile
-
class 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
Maximum pixel distance allowed when selecting end point of scan line.
limits : tuple or {None, ‘image’, ‘dtype’}
(minimum, maximum) intensity limits for plotted profile. The following special values are defined:
None : rescale based on min/max intensity along selected scan line. ‘image’ : fixed scale based on min/max intensity in image. ‘dtype’ : fixed scale based on min/max intensity of image dtype.
-
__init__(maxdist=10, epsilon='deprecated', limits='image', **kwargs)
[source]
-
attach(image_viewer)
[source]
-
get_profiles()
[source] -
Return intensity profile of the selected line.
Returns: end_points: (2, 2) array
The positions ((x1, y1), (x2, y2)) of the line ends.
profile: list of 1d arrays
Profile of intensity values. Length 1 (grayscale) or 3 (rgb).
-
help()
[source]
-
line_changed(end_points)
[source]
-
name = 'Line Profile'
-
output()
[source] -
Return the drawn line and the resulting scan.
Returns: line_image : (M, N) uint8 array, same shape as image
An array of 0s with the scanned line set to 255. If the linewidth of the line tool is greater than 1, sets the values within the profiled polygon to 128.
scan : (P,) or (P, 3) array of int or float
The line scan values across the image.
-
reset_axes(scan_data)
[source]
-
Measure
-
class skimage.viewer.plugins.Measure(maxdist=10, **kwargs)
[source] -
Bases:
skimage.viewer.plugins.base.Plugin
-
__init__(maxdist=10, **kwargs)
[source]
-
attach(image_viewer)
[source]
-
help()
[source]
-
line_changed(end_points)
[source]
-
name = 'Measure'
-
OverlayPlugin
-
class 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. -
__init__(**kwargs)
[source]
-
attach(image_viewer)
[source]
-
closeEvent(event)
[source]
-
color
-
colors = {'cyan': (0, 1, 1), 'green': (0, 1, 0), 'yellow': (1, 1, 0), 'red': (1, 0, 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
The overlay currently displayed.
data : None
-
overlay
-
PlotPlugin
-
class 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.
-
__init__(image_filter=None, height=150, width=400, **kwargs)
[source]
-
add_plot()
[source]
-
add_tool(tool)
[source]
-
attach(image_viewer)
[source]
-
redraw()
[source] -
Redraw plot.
-
remove_tool(tool)
[source]
-
Plugin
-
class skimage.viewer.plugins.Plugin(image_filter=None, height=0, width=400, useblit=True, dock='bottom')
[source] -
Bases:
PyQt4.QtGui.QDialog
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
Window containing image used in measurement/manipulation.
image_filter : function
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, width : int
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.useblit : bool
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_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. -
__init__(image_filter=None, height=0, width=400, useblit=True, dock='bottom')
[source]
-
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 kwargsNote:
display_filtered_image
is automatically called.
-
filtered_image
-
Return filtered image.
-
image_changed
-
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
self.image_viewer.image
, or NoneThe filtered image.
data : None
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.
-
© 2011 the scikit-image team
Licensed under the BSD 3-clause License.
http://scikit-image.org/docs/0.12.x/api/skimage.viewer.plugins.html