Module: viewer.plugins

CannyPlugin

class skimage.viewer.plugins.CannyPlugin(*args, **kwargs)

Bases: skimage.viewer.plugins.overlayplugin.OverlayPlugin

Canny filter plugin to show edges of an image.

__init__(*args, **kwargs)
attach(image_viewer)
name = 'Canny Filter'

ColorHistogram

class skimage.viewer.plugins.ColorHistogram(max_pct=0.99, **kwargs)

Bases: skimage.viewer.plugins.plotplugin.PlotPlugin

__init__(max_pct=0.99, **kwargs)
ab_selected(extents)
attach(image_viewer)
help()
name = 'Color Histogram'
output()

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. Keys:

  • ‘bins’ : array of float, the bin boundaries for both

    a and b 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.

Crop

class skimage.viewer.plugins.Crop(maxdist=10, **kwargs)

Bases: skimage.viewer.plugins.base.Plugin

__init__(maxdist=10, **kwargs)
attach(image_viewer)
crop(extents)
help()
name = 'Crop'

LabelPainter

class skimage.viewer.plugins.LabelPainter(max_radius=20, **kwargs)

Bases: skimage.viewer.plugins.base.Plugin

__init__(max_radius=20, **kwargs)
attach(image_viewer)
help()
label
name = 'LabelPainter'
on_enter(overlay)
radius

LineProfile

class skimage.viewer.plugins.LineProfile(maxdist=10, epsilon='deprecated', limits='image', **kwargs)

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)
attach(image_viewer)
get_profiles()

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()
line_changed(end_points)
name = 'Line Profile'
output()

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)

Measure

class skimage.viewer.plugins.Measure(maxdist=10, **kwargs)

Bases: skimage.viewer.plugins.base.Plugin

__init__(maxdist=10, **kwargs)
attach(image_viewer)
help()
line_changed(end_points)
name = 'Measure'

OverlayPlugin

class skimage.viewer.plugins.OverlayPlugin(**kwargs)

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
color
__init__(**kwargs)
attach(image_viewer)
closeEvent(event)
color
colors = {'cyan': (0, 1, 1), 'green': (0, 1, 0), 'yellow': (1, 1, 0), 'red': (1, 0, 0)}
display_filtered_image(image)

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()

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)

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)
add_plot()
attach(image_viewer)
redraw()

Redraw plot.

Plugin

class skimage.viewer.plugins.Plugin(image_filter=None, height=0, width=400, useblit=True, dock='bottom')

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            
>>> viewer.show()               

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