def reduce_height(img4, eng):
"""
Reduces the height by 1 pixel
Args:
img4 (n,m,4 numpy matrix): RGB image with additional mask layer.
eng (n,m numpy matrix): Pre-computed energy matrix for supplied image.
Returns:
tuple (
n,1 numpy matrix: the removed seam,
n-1,m,4 numpy matrix: The height-redcued image,
float: The cost of the seam removed
)
"""
flipped_eng = np.transpose(eng)
flipped_img4 = np.transpose(img4, (1, 0, 2))
flipped_seam, reduced_flipped_img4, cost = reduce_width(flipped_img4, flipped_eng)
return (
np.transpose(flipped_seam),
np.transpose(reduced_flipped_img4, (1, 0, 2)),
cost
)
评论列表
文章目录