mirror of
https://github.com/wassname/scikit-image.git
synced 2026-07-05 13:44:59 +08:00
@@ -1033,31 +1033,31 @@ def warp(image, inverse_map=None, map_args={}, output_shape=None, order=1,
|
||||
>>> image = data.camera()
|
||||
|
||||
The following image warps are all equal but differ substantially in
|
||||
execution time.
|
||||
execution time. The image is shifted to the bottom.
|
||||
|
||||
Use a geometric transform to warp an image (fast):
|
||||
|
||||
>>> from skimage.transform import SimilarityTransform
|
||||
>>> tform = SimilarityTransform(translation=(0, -10))
|
||||
>>> warp(image, tform) # doctest: +SKIP
|
||||
>>> warped = warp(image, tform)
|
||||
|
||||
Shift an image to the right with a callable (slow):
|
||||
Use a callable (slow):
|
||||
|
||||
>>> def shift(xy):
|
||||
>>> def shift_down(xy):
|
||||
... xy[:, 1] -= 10
|
||||
... return xy
|
||||
>>> warp(image, shift_right) # doctest: +SKIP
|
||||
>>> warped = warp(image, shift_down)
|
||||
|
||||
Use a transformation matrix to warp an image (fast):
|
||||
|
||||
>>> matrix = np.array([[1, 0, 0], [0, 1, -10], [0, 0, 1]])
|
||||
>>> warp(image, matrix) # doctest: +SKIP
|
||||
>>> warped = warp(image, matrix)
|
||||
>>> from skimage.transform import ProjectiveTransform
|
||||
>>> warp(image, ProjectiveTransform(matrix=matrix)) # doctest: +SKIP
|
||||
>>> warped = warp(image, ProjectiveTransform(matrix=matrix))
|
||||
|
||||
You can also use the inverse of a geometric transformation (fast):
|
||||
|
||||
>>> warp(image, tform.inverse) # doctest: +SKIP
|
||||
>>> warped = warp(image, tform.inverse)
|
||||
|
||||
"""
|
||||
# Backward API compatibility
|
||||
|
||||
@@ -29,21 +29,21 @@ def regular_grid(ar_shape, n_points):
|
||||
>>> ar = np.zeros((20, 40))
|
||||
>>> g = regular_grid(ar.shape, 8)
|
||||
>>> g
|
||||
[slice(5.0, None, 10.0), slice(5.0, None, 10.0)]
|
||||
[slice(5, None, 10), slice(5, None, 10)]
|
||||
>>> ar[g] = 1
|
||||
>>> ar.sum()
|
||||
8.0
|
||||
>>> ar = np.zeros((20, 40))
|
||||
>>> g = regular_grid(ar.shape, 32)
|
||||
>>> g
|
||||
[slice(2.0, None, 5.0), slice(2.0, None, 5.0)]
|
||||
[slice(2, None, 5), slice(2, None, 5)]
|
||||
>>> ar[g] = 1
|
||||
>>> ar.sum()
|
||||
32.0
|
||||
>>> ar = np.zeros((3, 20, 40))
|
||||
>>> g = regular_grid(ar.shape, 8)
|
||||
>>> g
|
||||
[slice(1.0, None, 3.0), slice(5.0, None, 10.0), slice(5.0, None, 10.0)]
|
||||
[slice(1, None, 3), slice(5, None, 10), slice(5, None, 10)]
|
||||
>>> ar[g] = 1
|
||||
>>> ar.sum()
|
||||
8.0
|
||||
|
||||
@@ -16,7 +16,6 @@ else:
|
||||
has_qt = False
|
||||
|
||||
|
||||
@doctest_skip_parser
|
||||
class Plugin(QtGui.QDialog):
|
||||
"""Base class for plugins that interact with an ImageViewer.
|
||||
|
||||
@@ -60,12 +59,12 @@ class Plugin(QtGui.QDialog):
|
||||
>>> from skimage import data
|
||||
>>>
|
||||
>>> plugin = Plugin(image_filter=lambda img,
|
||||
... threshold: img > threshold) # skip if not has_qt
|
||||
>>> plugin += Slider('threshold', 0, 255) # skip if not has_qt
|
||||
... threshold: img > threshold) # doctest: +SKIP
|
||||
>>> plugin += Slider('threshold', 0, 255) # doctest: +SKIP
|
||||
>>>
|
||||
>>> image = data.coins()
|
||||
>>> viewer = ImageViewer(image) # skip if not has_qt
|
||||
>>> viewer += plugin # skip if not has_qt
|
||||
>>> viewer = ImageViewer(image) # doctest: +SKIP
|
||||
>>> viewer += plugin # doctest: +SKIP
|
||||
>>> viewer.show() # doctest: +SKIP
|
||||
|
||||
The plugin will automatically delegate parameters to `image_filter` based
|
||||
|
||||
@@ -51,7 +51,6 @@ def mpl_image_to_rgba(mpl_image):
|
||||
return img_as_float(image)
|
||||
|
||||
|
||||
@doctest_skip_parser
|
||||
class ImageViewer(QtGui.QMainWindow):
|
||||
"""Viewer for displaying images.
|
||||
|
||||
@@ -79,7 +78,7 @@ class ImageViewer(QtGui.QMainWindow):
|
||||
--------
|
||||
>>> from skimage import data
|
||||
>>> image = data.coins()
|
||||
>>> viewer = ImageViewer(image) # skip if not has_qt
|
||||
>>> viewer = ImageViewer(image) # doctest: +SKIP
|
||||
>>> viewer.show() # doctest: +SKIP
|
||||
|
||||
"""
|
||||
|
||||
Reference in New Issue
Block a user