Modfied test to use new API and added code to remove remaining seams if any

This commit is contained in:
Vighnesh Birodkar
2015-06-11 00:47:13 +05:30
parent 17dc213477
commit 3f9c800514
2 changed files with 6 additions and 18 deletions
+2
View File
@@ -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]
+4 -18
View File
@@ -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)