mirror of
https://github.com/wassname/scikit-image.git
synced 2026-07-08 05:22:31 +08:00
Merge pull request #1382 from arve0/ImageViewer.update_image
move CollectionViewer `update_image` to parent class
This commit is contained in:
@@ -153,6 +153,9 @@ class ImageViewer(QtWidgets.QMainWindow):
|
||||
for showing images. `ImageViewer` doesn't subclass the Matplotlib axes (or
|
||||
figure) because of the high probability of name collisions.
|
||||
|
||||
Subclasses and plugins will likely extend the `update_image` method to add
|
||||
custom overlays or filter the displayed image.
|
||||
|
||||
Parameters
|
||||
----------
|
||||
image : array
|
||||
@@ -283,6 +286,14 @@ class ImageViewer(QtWidgets.QMainWindow):
|
||||
image = io.imread(filename)
|
||||
self._update_original_image(image)
|
||||
|
||||
def update_image(self, image):
|
||||
"""Update displayed image.
|
||||
|
||||
This method can be overridden or extended in subclasses and plugins to
|
||||
react to image changes.
|
||||
"""
|
||||
self._update_original_image(image)
|
||||
|
||||
def _update_original_image(self, image):
|
||||
self.original_image = image # update saved image
|
||||
self.image = image.copy() # update displayed image
|
||||
@@ -423,9 +434,6 @@ class CollectionViewer(ImageViewer):
|
||||
home/end keys
|
||||
First/last image in collection.
|
||||
|
||||
Subclasses and plugins will likely extend the `update_image` method to add
|
||||
custom overlays or filter the displayed image.
|
||||
|
||||
Parameters
|
||||
----------
|
||||
image_collection : list of images
|
||||
@@ -472,14 +480,6 @@ class CollectionViewer(ImageViewer):
|
||||
self.slider.val = index
|
||||
self.update_image(self.image_collection[index])
|
||||
|
||||
def update_image(self, image):
|
||||
"""Update displayed image.
|
||||
|
||||
This method can be overridden or extended in subclasses and plugins to
|
||||
react to image changes.
|
||||
"""
|
||||
self._update_original_image(image)
|
||||
|
||||
def keyPressEvent(self, event):
|
||||
if type(event) == QtWidgets.QKeyEvent:
|
||||
key = event.key()
|
||||
|
||||
Reference in New Issue
Block a user