From 9b4f2d903202f76e70b1d1ff4e790355cc1e3836 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johannes=20Sch=C3=B6nberger?= Date: Mon, 15 Sep 2014 23:34:33 -0400 Subject: [PATCH] Add support for 2(+1)D images and given output_shape for 2D images --- skimage/transform/_geometric.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/skimage/transform/_geometric.py b/skimage/transform/_geometric.py index bba323b8..4a1ce6a4 100644 --- a/skimage/transform/_geometric.py +++ b/skimage/transform/_geometric.py @@ -1180,6 +1180,13 @@ def warp(image, inverse_map=None, map_args={}, output_shape=None, order=1, def coord_map(*args): return inverse_map(*args, **map_args) + # Input image is 2D and has color channel, but output_shape is + # given for 2-D images. Automatically add the color channel + # dimensionality. + if len(input_shape) == 3 and len(output_shape) == 2: + output_shape = (output_shape[0], output_shape[1], + input_shape[2]) + coords = warp_coords(coord_map, output_shape) # Pre-filtering not necessary for order 0, 1 interpolation