mirror of
https://github.com/wassname/scikit-image.git
synced 2026-07-24 13:20:43 +08:00
Merge pull request #881 from blink1073/fix-labelpainter-609
Fix: Viewer: LabelPainter overlay does not update with new loaded image #609
This commit is contained in:
@@ -50,8 +50,7 @@ class PaintTool(CanvasToolBase):
|
||||
self.alpha = alpha
|
||||
self.cmap = LABELS_CMAP
|
||||
self._overlay_plot = None
|
||||
self._shape = overlay_shape
|
||||
self.overlay = np.zeros(overlay_shape, dtype='uint8')
|
||||
self.shape = overlay_shape
|
||||
|
||||
self._cursor = plt.Rectangle((0, 0), 0, 0, **props)
|
||||
self._cursor.set_visible(False)
|
||||
@@ -109,6 +108,19 @@ class PaintTool(CanvasToolBase):
|
||||
self._overlay_plot.set_data(image)
|
||||
self.redraw()
|
||||
|
||||
@property
|
||||
def shape(self):
|
||||
return self._shape
|
||||
|
||||
@shape.setter
|
||||
def shape(self, shape):
|
||||
self._shape = shape
|
||||
if not self._overlay_plot is None:
|
||||
self._overlay_plot.set_extent((-0.5, shape[1] + 0.5,
|
||||
shape[0] + 0.5, -0.5))
|
||||
self.radius = self._radius
|
||||
self.overlay = np.zeros(shape, dtype='uint8')
|
||||
|
||||
def _on_key_press(self, event):
|
||||
if event.key == 'enter':
|
||||
self.callback_on_enter(self.geometry)
|
||||
|
||||
@@ -43,6 +43,10 @@ class LabelPainter(Plugin):
|
||||
self.paint_tool.label = self._label_widget.index = 1
|
||||
self.artists.append(self.paint_tool)
|
||||
|
||||
def _on_new_image(self, image):
|
||||
"""Update plugin for new images."""
|
||||
self.paint_tool.shape = image.shape
|
||||
|
||||
def on_enter(self, overlay):
|
||||
pass
|
||||
|
||||
|
||||
Reference in New Issue
Block a user