diff --git a/skimage/transform/_seam_carving.pyx b/skimage/transform/_seam_carving.pyx index 41ea1d75..7159e38a 100644 --- a/skimage/transform/_seam_carving.pyx +++ b/skimage/transform/_seam_carving.pyx @@ -202,4 +202,6 @@ def _seam_carve_v(img, energy_map, iters, border): last_row[:cols] = cumulative_img[-1, :cols] sorted_indices = np.argsort(last_row_obj) + _remove_seam(image, seam_map, cols) + return img[:, 0:cols] diff --git a/skimage/transform/tests/test_seam_carving.py b/skimage/transform/tests/test_seam_carving.py index 57df75e0..1ff0b32e 100644 --- a/skimage/transform/tests/test_seam_carving.py +++ b/skimage/transform/tests/test_seam_carving.py @@ -3,34 +3,20 @@ import numpy as np from numpy import testing -def energy(img): - if(img.ndim == 3): - img = np.ascontiguousarray(img[:, :, 0]) - return (1 - img) - - def test_seam_carving(): img = np.array([[0, 0, 1, 0, 0], [0, 0, 1, 0, 0], [0, 0, 1, 0, 0], [0, 1, 0, 0, 0], [1, 0, 0, 0, 0]], dtype=np.float) + energy = 1 - img - out = transform.seam_carve(img, 'horizontal', 1, energy, border=0) + out = transform.seam_carve(img, energy, 'vertical', 1, border=0) + print out testing.assert_allclose(out, 0) img = img.T - out = transform.seam_carve(img, 'vertical', 1, energy, border=0) - testing.assert_allclose(out, 0) - - img = img.T - - img3 = np.dstack([img, img, img]) - - out = transform.seam_carve(img3, 'horizontal', 1, energy, border=0) - testing.assert_allclose(out, 0) - - out = transform.seam_carve(img3, 'vertical', 1, energy, border=0) + out = transform.seam_carve(img, energy, 'horizontal', 1, border=0) testing.assert_allclose(out, 0)