mirror of
https://github.com/wassname/scikit-image.git
synced 2026-07-04 03:53:26 +08:00
Only clip for ndimage.map_coordinates case
This commit is contained in:
@@ -1052,15 +1052,17 @@ def warp(image, inverse_map=None, map_args={}, output_shape=None, order=1,
|
||||
out = ndimage.map_coordinates(image, coords, prefilter=prefilter,
|
||||
mode=mode, order=order, cval=cval)
|
||||
|
||||
# The spline filters sometimes return results outside [0, 1],
|
||||
# so clip to ensure valid data
|
||||
clipped = np.clip(out, 0, 1)
|
||||
# The spline filters sometimes return results outside [0, 1],
|
||||
# so clip to ensure valid data
|
||||
clipped = np.clip(out, 0, 1)
|
||||
|
||||
if mode == 'constant' and not (0 <= cval <= 1):
|
||||
clipped[out == cval] = cval
|
||||
if mode == 'constant' and not (0 <= cval <= 1):
|
||||
clipped[out == cval] = cval
|
||||
|
||||
if clipped.ndim == 3 and orig_ndim == 2:
|
||||
# remove singleton dim introduced by atleast_3d
|
||||
return clipped[..., 0]
|
||||
out = clipped
|
||||
|
||||
if out.ndim == 3 and orig_ndim == 2:
|
||||
# remove singleton dimension introduced by atleast_3d
|
||||
return out[..., 0]
|
||||
else:
|
||||
return clipped
|
||||
return out
|
||||
|
||||
Reference in New Issue
Block a user