From 875270cb78aac8b543f41b03f3940ed6d8cbeff9 Mon Sep 17 00:00:00 2001 From: Adam Ginsburg Date: Tue, 25 Dec 2012 14:25:17 -0700 Subject: [PATCH 1/2] very slight change to warp_coords docstring, but I think slightly more illustrative of the shape of the array --- skimage/transform/_geometric.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/skimage/transform/_geometric.py b/skimage/transform/_geometric.py index 1179811d..11effb8a 100644 --- a/skimage/transform/_geometric.py +++ b/skimage/transform/_geometric.py @@ -874,18 +874,18 @@ def warp_coords(coord_map, shape, dtype=np.float64): Examples -------- - Produce a coordinate map that Shifts an image to the right: + Produce a coordinate map that Shifts an image up and to the right: >>> from skimage import data >>> from scipy.ndimage import map_coordinates >>> - >>> def shift_right(xy): - ... xy[:, 0] -= 10 - ... return xy + >>> def shift_up1_left2(xy): + ... return xy-np.array([-2,1])[:,None] >>> >>> image = data.lena().astype(np.float32) >>> coords = warp_coords(shift_right, image.shape) >>> warped_image = map_coordinates(image, coords) + >>> """ rows, cols = shape[0], shape[1] From 0824af0e3ac01aae3ca8a19e31de781b942d8059 Mon Sep 17 00:00:00 2001 From: Adam Ginsburg Date: Tue, 25 Dec 2012 14:27:49 -0700 Subject: [PATCH 2/2] looks like I didn't save on the previous commit; these should be squashed with the previous commit message --- skimage/transform/_geometric.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/skimage/transform/_geometric.py b/skimage/transform/_geometric.py index 11effb8a..6c5cb2c0 100644 --- a/skimage/transform/_geometric.py +++ b/skimage/transform/_geometric.py @@ -848,6 +848,8 @@ def warp_coords(coord_map, shape, dtype=np.float64): ---------- coord_map : callable like GeometricTransform.inverse Return input coordinates for given output coordinates. + Coordinates are in the shape (P,2), where P is the number + of coordinates and each element is an x,y pair shape : tuple Shape of output image ``(rows, cols[, bands])``. dtype : np.dtype or string @@ -879,11 +881,11 @@ def warp_coords(coord_map, shape, dtype=np.float64): >>> from skimage import data >>> from scipy.ndimage import map_coordinates >>> - >>> def shift_up1_left2(xy): - ... return xy-np.array([-2,1])[:,None] + >>> def shift_up10_left20(xy): + ... return xy-np.array([-20,10])[None,:] >>> >>> image = data.lena().astype(np.float32) - >>> coords = warp_coords(shift_right, image.shape) + >>> coords = warp_coords(shift_up10_left20, image.shape) >>> warped_image = map_coordinates(image, coords) >>>