赞
踩
您可以使用scikit-image中的skimage.transform.ProjectiveTransform将四边形内部的坐标转换为局部正方形空间[0,1]×[0,1].
假设您按顺时针顺序有四边形的角:
bottom_left = [58.6539, 31.512]
top_left = [27.8129, 127.462]
top_right = [158.03, 248.769]
bottom_right = [216.971, 84.2843]
我们实例化一个ProjectiveTransform,并要求它在四边形到单位正方形的内侧找到投影变换映射点:
from skimage.transform import ProjectiveTransform
t = ProjectiveTransform()
src = np.asarray(
[bottom_left, top_left, top_right, bottom_right])
dst = np.asarray([[0, 0], [0, 1], [1, 1], [1, 0]])
if not t.estimate(src, dst): raise Exception("estimate failed")
现在,转换t已准备好将您的点转换为单位平方.当然,通过更改上面的dst,您可以缩放到与单位正方形不同的矩形(甚至缩放到完全不同的四边形).
data = np.asarray([
[69.1216, 51.7061], [72.7985, 73.2601], [75.9628, 91.8095],
[79.7145, 113.802], [83.239, 134.463], [86.6833, 154.654],
[88.
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。