mirror of
https://github.com/wassname/scikit-image.git
synced 2026-07-13 17:45:20 +08:00
ENH: filter image when Plugin is attached to ImageViewer
This commit is contained in:
@@ -32,8 +32,7 @@ class Plugin(QtGui.QDialog):
|
||||
super(Plugin, self).__init__()
|
||||
|
||||
self.image_viewer = None
|
||||
if image_filter is not None:
|
||||
self.image_filter = image_filter
|
||||
self.image_filter = image_filter
|
||||
|
||||
self.setWindowTitle(self.name)
|
||||
self.layout = QtGui.QGridLayout(self)
|
||||
@@ -70,6 +69,8 @@ class Plugin(QtGui.QDialog):
|
||||
|
||||
if self.draws_on_image:
|
||||
self.connect_image_event('draw_event', self.on_draw)
|
||||
# Call filter so that filtered image matches widget values
|
||||
self.filter_image()
|
||||
|
||||
def on_draw(self, event):
|
||||
"""Save image background when blitting.
|
||||
@@ -81,6 +82,8 @@ class Plugin(QtGui.QDialog):
|
||||
self.img_background = self.image_viewer.canvas.copy_from_bbox(bbox)
|
||||
|
||||
def filter_image(self, *args):
|
||||
if self.image_filter is None:
|
||||
return
|
||||
arguments = [self._get_value(a) for a in self.arguments]
|
||||
kwargs = dict([(name, self._get_value(a))
|
||||
for name, a in self.keyword_arguments.iteritems()])
|
||||
|
||||
@@ -15,8 +15,3 @@ class CannyPlugin(OverlayPlugin):
|
||||
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'))
|
||||
|
||||
def attach(self, image_viewer):
|
||||
super(CannyPlugin, self).attach(image_viewer)
|
||||
# Update image overlay to default slider values.
|
||||
self.filter_image()
|
||||
|
||||
Reference in New Issue
Block a user