imutils.py 文件源码

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

项目:VLTPF 作者: avigan 项目源码 文件源码
def _rotate_interp(array, alpha, center, mode='constant', cval=0):
    '''
    Rotation around a provided center

    This is the only way to be sure where exactly is the center of rotation.

    '''
    dtype = array.dtype
    dims  = array.shape
    alpha_rad = -np.deg2rad(alpha)

    x, y = np.meshgrid(np.arange(dims[1], dtype=dtype), np.arange(dims[0], dtype=dtype))

    xp = (x-center[0])*np.cos(alpha_rad) + (y-center[1])*np.sin(alpha_rad) + center[0]
    yp = -(x-center[0])*np.sin(alpha_rad) + (y-center[1])*np.cos(alpha_rad) + center[1]

    rotated = ndimage.map_coordinates(img, [yp, xp], mode=mode, cval=cval, order=3)

    return rotated
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号