seam_carver.py 文件源码

python
阅读 29 收藏 0 点赞 0 评论 0

项目:seam_carving 作者: dharness 项目源码 文件源码
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
    )
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号