mirror of
https://github.com/wassname/scikit-image.git
synced 2026-07-27 11:27:08 +08:00
add reset button to crop plugin
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
from .base import Plugin
|
||||
from ..canvastools import RectangleTool
|
||||
from ...viewer.widgets import SaveButtons
|
||||
from ...viewer.widgets import SaveButtons, Button
|
||||
|
||||
|
||||
__all__ = ['Crop']
|
||||
@@ -23,6 +23,9 @@ class Crop(Plugin):
|
||||
on_enter=self.crop)
|
||||
self.artists.append(self.rect_tool)
|
||||
|
||||
self.reset_button = Button('Reset', self.reset)
|
||||
self.add_widget(self.reset_button)
|
||||
|
||||
def help(self):
|
||||
helpstr = ("Crop tool",
|
||||
"Select rectangular region and press enter to crop.")
|
||||
@@ -30,6 +33,13 @@ class Crop(Plugin):
|
||||
|
||||
def crop(self, extents):
|
||||
xmin, xmax, ymin, ymax = extents
|
||||
if xmin == xmax or ymin == ymax:
|
||||
return
|
||||
image = self.image_viewer.image[ymin:ymax+1, xmin:xmax+1]
|
||||
self.image_viewer.image = image
|
||||
self.image_viewer.ax.relim()
|
||||
|
||||
def reset(self):
|
||||
self.rect_tool.extents = -10, -10, -10, -10
|
||||
self.image_viewer.image = self.image_viewer.original_image
|
||||
self.image_viewer.ax.relim()
|
||||
|
||||
Reference in New Issue
Block a user