def seam_carve(img, energy_map, mode, num, border=1, force_copy=True):
 utils.assert_nD(img, (2, 3))
 image = util.img_as_float(img, force_copy)
 energy_map = util.img_as_float(energy_map, force_copy)
 if (image.ndim == 2):
  image = image[..., np.newaxis]
 if (mode == 'horizontal'):
  image = np.transpose(image, (1, 0, 2))
 image = np.ascontiguousarray(image)
 out = _seam_carve_v(image, energy_map, num, border)
 if (mode == 'horizontal'):
  out = np.transpose(out, (1, 0, 2))
 return np.squeeze(out)

def seam_carve ( img , energy_map , mode , num , border = 1 , force_copy = True ) : utils . assert_nD ( img , ( 2 , 3 ) ) image = util . img_as_float ( img , force_copy ) energy_map = util . img_as_float ( energy_map , force_copy ) if ( image . ndim == 2 ) : image = image [ ... , np . newaxis ] if ( mode == 'horizontal' ) : image = np . transpose ( image , ( 1 , 0 , 2 ) ) image = np . ascontiguousarray ( image ) out = _seam_carve_v ( image , energy_map , num , border ) if ( mode == 'horizontal' ) : out = np . transpose ( out , ( 1 , 0 , 2 ) ) return np . squeeze ( out )
carve vertical or horizontal seams off an image .