diff --git a/skimage/viewer/plugins/base.py b/skimage/viewer/plugins/base.py index 50b7601c..fe8634bb 100644 --- a/skimage/viewer/plugins/base.py +++ b/skimage/viewer/plugins/base.py @@ -182,8 +182,13 @@ class Plugin(QtGui.QDialog): This method is called by the viewer when the original image is updated. """ self.arguments[0] = image + self._on_new_image(image) self.filter_image() + def _on_new_image(self, image): + """Override this method to update your plugin for new images.""" + pass + @property def filtered_image(self): """Return filtered image.""" diff --git a/skimage/viewer/plugins/color_histogram.py b/skimage/viewer/plugins/color_histogram.py index 39a75004..2d8c66b7 100644 --- a/skimage/viewer/plugins/color_histogram.py +++ b/skimage/viewer/plugins/color_histogram.py @@ -20,7 +20,10 @@ class ColorHistogram(PlotPlugin): super(ColorHistogram, self).attach(image_viewer) self.rect_tool = RectangleTool(self.ax, on_release=self.ab_selected) - self.lab_image = color.rgb2lab(image_viewer.image) + self._on_new_image(image_viewer.image) + + def _on_new_image(self, image): + self.lab_image = color.rgb2lab(image) # Calculate color histogram in the Lab colorspace: L, a, b = self.lab_image.T diff --git a/skimage/viewer/plugins/plotplugin.py b/skimage/viewer/plugins/plotplugin.py index 0ce5df73..5de6be7b 100644 --- a/skimage/viewer/plugins/plotplugin.py +++ b/skimage/viewer/plugins/plotplugin.py @@ -47,3 +47,7 @@ class PlotPlugin(Plugin): bgcolor = str(bgcolor / 255.) self.fig.patch.set_facecolor(bgcolor) self.layout.addWidget(self.canvas, self.row, 0) + + def _update_original_image(self, image): + super(PlotPlugin, self)._update_original_image(image) + self.redraw()