restore opencv-based code path in affine_transform
This was inadvertently removed in
fix mode opencv for rotate and shift as well
@@ -175,6 +175,17 @@ def affine_transform(input, matrix, offset=0.0, output_shape=None, output=None,
if output_shape is None:
output_shape = input.shape
+ if mode == 'opencv' or mode == '_opencv_edge':
+ if matrix.ndim == 1:
+ matrix = cupy.diag(matrix)
+ coordinates = cupy.indices(output_shape, dtype=cupy.float64)
+ coordinates = cupy.dot(matrix, coordinates.reshape((input.ndim, -1)))
+ coordinates += cupy.expand_dims(cupy.asarray(offset), -1)
+ ret = _util._get_output(output, input, shape=output_shape)
+ ret[:] = map_coordinates(input, coordinates, ret.dtype, order, mode,
+ cval, prefilter).reshape(output_shape)
+ return ret
+
matrix = matrix.astype(cupy.float64, copy=False)
if order is None:
order = 1
