mirror of
https://github.com/wassname/scikit-image.git
synced 2026-08-04 13:14:23 +08:00
Modfied test to use new API and added code to remove remaining seams if any
This commit is contained in:
@@ -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]
|
||||
|
||||
@@ -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)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user