mirror of
https://github.com/wassname/scikit-image.git
synced 2026-08-01 12:50:48 +08:00
The `ptype` parameter of widget can now be set to 'plugin'. When this is the case, the plugin will set a plugin attribute whenever the widget is updated. As an example, this commit adds a ComboBox widget which is hooked into the overlay color of the OverlayPlugin.
26 lines
944 B
Python
26 lines
944 B
Python
from skimage.filter import canny
|
|
|
|
from .overlayplugin import OverlayPlugin
|
|
from ..widgets import Slider, ComboBox
|
|
|
|
|
|
class CannyPlugin(OverlayPlugin):
|
|
|
|
name = 'Canny Filter'
|
|
|
|
def __init__(self, image_viewer, *args, **kwargs):
|
|
height = kwargs.get('height', 100)
|
|
width = kwargs.get('width', 400)
|
|
super(CannyPlugin, self).__init__(image_viewer,
|
|
width=width, height=height)
|
|
self.add_widget(Slider('sigma', 0, 5, update_on='release'))
|
|
self.add_widget(Slider('low threshold', 0, 255, update_on='release'))
|
|
self.add_widget(Slider('high threshold', 0, 255, update_on='release'))
|
|
self.add_widget(ComboBox('color', self.color_names, ptype='plugin'))
|
|
# Update image overlay to default slider values.
|
|
self.filter_image()
|
|
|
|
def image_filter(self, *args, **kwargs):
|
|
image = canny(*args, **kwargs)
|
|
self.overlay = image
|