imageutil.py 文件源码

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

项目:nuts-ml 作者: maet3608 项目源码 文件源码
def translate(image, dx, dy, **kwargs):
    """
    Shift image horizontally and vertically

    >>> image = np.eye(3, dtype='uint8') * 255
    >>> translate(image, 2, 1)
    array([[  0,   0,   0],
           [  0,   0, 255],
           [  0,   0,   0]], dtype=uint8)

    :param numpy array image: Numpy array with range [0,255] and dtype 'uint8'.
    :param dx: horizontal translation in pixels
    :param dy: vertical translation in pixels
    :param kwargs kwargs: Keyword arguments for the underlying scikit-image
       rotate function, e.g. order=1 for linear interpolation.
    :return: translated image
    :rtype:  numpy array with range [0,255] and dtype 'uint8'
    """
    set_default_order(kwargs)
    transmat = skt.AffineTransform(translation=(-dx, -dy))
    return skt.warp(image, transmat, preserve_range=True,
                    **kwargs).astype('uint8')
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号