def scale_to_fit(img, size):
"""
Scales an image to a given size by warping with no regard to the ratio.
Returns: warped image as ndarray
"""
width = len(img[0])
height = len(img)
src = numpy.array((
(0, 0),
(0, size[1]),
(size[0], size[1]),
(size[0], 0)
))
dst = numpy.array((
(0, 0),
(0, height),
(width, height),
(width, 0)
))
tform = transform.ProjectiveTransform()
tform.estimate(src, dst)
return transform.warp(img, tform, output_shape=(size[1],size[0]))
#########################################################################################################
#########################################################################################################
cv.py 文件源码
python
阅读 27
收藏 0
点赞 0
评论 0
评论列表
文章目录