From c2023e9975946fdefe88c624e745ee6c6eb8b6cb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johannes=20Sch=C3=B6nberger?= Date: Tue, 26 Feb 2013 12:12:02 +0100 Subject: [PATCH 1/4] Remove duplicate return statement --- skimage/transform/_warps.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/skimage/transform/_warps.py b/skimage/transform/_warps.py index 0ace0937..5af3afa6 100644 --- a/skimage/transform/_warps.py +++ b/skimage/transform/_warps.py @@ -348,6 +348,3 @@ def homography(image, H, output_shape=None, order=1, tform = ProjectiveTransform(H) return warp(image, inverse_map=tform.inverse, output_shape=output_shape, order=order, mode=mode, cval=cval) - - return warp(image, inverse_map=tform.inverse, output_shape=output_shape, - order=order, mode=mode, cval=cval) From 72e1d20a2948b166b0cea311290cdbec1610e414 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johannes=20Sch=C3=B6nberger?= Date: Tue, 26 Feb 2013 12:22:13 +0100 Subject: [PATCH 2/4] Remove deprecated homography function --- skimage/transform/_warps.py | 95 ------------------------------------- 1 file changed, 95 deletions(-) diff --git a/skimage/transform/_warps.py b/skimage/transform/_warps.py index 5af3afa6..7ac3e63f 100644 --- a/skimage/transform/_warps.py +++ b/skimage/transform/_warps.py @@ -253,98 +253,3 @@ def swirl(image, center=None, strength=1, radius=100, rotation=0, return warp(image, _swirl_mapping, map_args=warp_args, output_shape=output_shape, order=order, mode=mode, cval=cval) - - -def homography(image, H, output_shape=None, order=1, - mode='constant', cval=0.): - """ - .. note:: Deprecated in skimage 0.7 - `homography` will be removed in skimage 0.8, it is replaced by - `warp` because the latter provides the same functionality:: - - warp(image, ProjectiveTransform(H)) - - Perform a projective transformation (homography) on an image. - - For each pixel, given its homogeneous coordinate :math:`\mathbf{x} - = [x, y, 1]^T`, its target position is calculated by multiplying - with the given matrix, :math:`H`, to give :math:`H \mathbf{x}`. - E.g., to rotate by theta degrees clockwise, the matrix should be - - :: - - [[cos(theta) -sin(theta) 0] - [sin(theta) cos(theta) 0] - [0 0 1]] - - or, to translate x by 10 and y by 20, - - :: - - [[1 0 10] - [0 1 20] - [0 0 1 ]]. - - Parameters - ---------- - image : 2-D array - Input image. - H : array of shape ``(3, 3)`` - Transformation matrix H that defines the homography. - output_shape : tuple (rows, cols) - Shape of the output image generated. - order : int - Order of splines used in interpolation. - mode : string - How to handle values outside the image borders. Passed as-is - to ndimage. - cval : string - Used in conjunction with mode 'constant', the value outside - the image boundaries. - - Examples - -------- - >>> # rotate by 90 degrees around origin and shift down by 2 - >>> x = np.arange(9, dtype=np.uint8).reshape((3, 3)) + 1 - >>> x - array([[1, 2, 3], - [4, 5, 6], - [7, 8, 9]], dtype=uint8) - >>> theta = -np.pi/2 - >>> M = np.array([[np.cos(theta),-np.sin(theta),0], - ... [np.sin(theta), np.cos(theta),2], - ... [0, 0, 1]]) - >>> x90 = homography(x, M, order=1) - >>> x90 - array([[3, 6, 9], - [2, 5, 8], - [1, 4, 7]], dtype=uint8) - >>> # translate right by 2 and down by 1 - >>> y = np.zeros((5,5), dtype=np.uint8) - >>> y[1, 1] = 255 - >>> y - array([[ 0, 0, 0, 0, 0], - [ 0, 255, 0, 0, 0], - [ 0, 0, 0, 0, 0], - [ 0, 0, 0, 0, 0], - [ 0, 0, 0, 0, 0]], dtype=uint8) - >>> M = np.array([[ 1., 0., 2.], - ... [ 0., 1., 1.], - ... [ 0., 0., 1.]]) - >>> y21 = homography(y, M, order=1) - >>> y21 - array([[ 0, 0, 0, 0, 0], - [ 0, 0, 0, 0, 0], - [ 0, 0, 0, 255, 0], - [ 0, 0, 0, 0, 0], - [ 0, 0, 0, 0, 0]], dtype=uint8) - - """ - import warnings - warnings.warn('the homography function is deprecated; ' - 'use the `warp` and `ProjectiveTransform` class instead', - category=DeprecationWarning) - - tform = ProjectiveTransform(H) - return warp(image, inverse_map=tform.inverse, output_shape=output_shape, - order=order, mode=mode, cval=cval) From f2d91d2c296e3662a1b656f0fdf5191665ff363b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johannes=20Sch=C3=B6nberger?= Date: Tue, 26 Feb 2013 16:57:43 +0100 Subject: [PATCH 3/4] Remove deprecated import of hompgraphy --- skimage/transform/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/skimage/transform/__init__.py b/skimage/transform/__init__.py index befcc23f..089487ee 100644 --- a/skimage/transform/__init__.py +++ b/skimage/transform/__init__.py @@ -6,6 +6,6 @@ from ._geometric import (warp, warp_coords, estimate_transform, SimilarityTransform, AffineTransform, ProjectiveTransform, PolynomialTransform, PiecewiseAffineTransform) -from ._warps import swirl, homography, resize, rotate, rescale +from ._warps import swirl, resize, rotate, rescale from .pyramids import (pyramid_reduce, pyramid_expand, pyramid_gaussian, pyramid_laplacian) From 374a967ffc76a34971043630ad6b0221629e838c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johannes=20Sch=C3=B6nberger?= Date: Wed, 27 Feb 2013 08:45:45 +0100 Subject: [PATCH 4/4] Remove deprecated tests for homography --- skimage/transform/tests/test_warps.py | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/skimage/transform/tests/test_warps.py b/skimage/transform/tests/test_warps.py index 2cdda001..93f87320 100644 --- a/skimage/transform/tests/test_warps.py +++ b/skimage/transform/tests/test_warps.py @@ -5,7 +5,7 @@ from scipy.ndimage import map_coordinates from skimage.transform import (warp, warp_coords, rotate, resize, rescale, AffineTransform, ProjectiveTransform, - SimilarityTransform, homography) + SimilarityTransform) from skimage import transform as tf, data, img_as_float from skimage.color import rgb2gray @@ -39,10 +39,6 @@ def test_homography(): assert_array_almost_equal(x90, np.rot90(x)) -def test_homography_basic(): - homography(np.random.random((25, 25)), np.eye(3)) - - def test_fast_homography(): img = rgb2gray(data.lena()).astype(np.uint8) img = img[:, :100] @@ -87,10 +83,10 @@ def test_rotate(): def test_rotate_resize(): x = np.zeros((10, 10), dtype=np.double) - + x45 = rotate(x, 45, resize=False) assert x45.shape == (10, 10) - + x45 = rotate(x, 45, resize=True) # new dimension should be d = sqrt(2 * (10/2)^2) assert x45.shape == (14, 14)