mirror of
https://github.com/wassname/scikit-image.git
synced 2026-06-28 22:54:02 +08:00
Added test case for warp() when cval out of clipping range
This commit is contained in:
committed by
Johannes Schönberger
parent
0749f8d9f0
commit
e710fac03e
@@ -786,6 +786,7 @@ def warp(image, inverse_map=None, map_args={}, output_shape=None, order=1,
|
||||
# The spline filters sometimes return results outside [0, 1],
|
||||
# so clip to ensure valid data
|
||||
clipped = np.clip(mapped, 0, 1)
|
||||
|
||||
if mode == 'constant' and not (0 <= cval <= 1):
|
||||
clipped[mapped == cval] = cval
|
||||
|
||||
|
||||
@@ -2,7 +2,8 @@ from numpy.testing import assert_array_almost_equal, run_module_suite
|
||||
import numpy as np
|
||||
|
||||
from skimage.transform import (warp, homography, fast_homography,
|
||||
SimilarityTransform, ProjectiveTransform)
|
||||
SimilarityTransform, ProjectiveTransform,
|
||||
AffineTransform)
|
||||
from skimage import transform as tf, data, img_as_float
|
||||
from skimage.color import rgb2gray
|
||||
|
||||
@@ -74,5 +75,12 @@ def test_swirl():
|
||||
assert np.mean(np.abs(image - unswirled)) < 0.01
|
||||
|
||||
|
||||
def test_const_cval_out_of_range():
|
||||
img = np.random.randn(100, 100)
|
||||
warped = warp(img, AffineTransform(translation=(10, 10)), cval=-10)
|
||||
assert np.any(warped < 0)
|
||||
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
run_module_suite()
|
||||
|
||||
Reference in New Issue
Block a user