python仿射6p库用于估计两组二维点之间的仿射变换参数

affine6p的Python项目详细描述


python affine6p库用于估计两组二维点之间的仿射变换参数。

| x' |   | a  b  p | | x |
| y' | = | c  d  q | | y |
| 1  |   | 0  0  1 | | 1 |
Example transformation

当集大于三点时,用最小二乘法估计lib参数。

在制作这个库的时候,我用了很多的想法。参考号:https://github.com/axelpale/nudged-py

安装

使用pip:

pip install affine6p

用法

您有转换函数的originalconverted要估计的点列表:

import affine6p
origin = [[0,0], [1,0], [0,1], [1,1]]
convert = [[0,0], [1,0], [0,1], [1,1.1]]
trans = affine6p.estimate(origin, convert)
trans.get_matrix()
# [[1.0, 0.0, 0.0],
# [0.050000000000000044, 1.05, -0.02499999999999991],
# [0, 0, 1]]
affine6p.estimate_error(trans, origin, convert)
# 0.025000000000000022

当原点数为1时,假设如下关系:

a = d = 1 and b = c = 0

当原点数为2时,假设如下关系如estimate_helmert中所述:

a = d and b = -c

您可以访问transform类成员

trans.a() # params[0]
trans.b() # params[1]
trans.c() # params[2]
trans.d() # params[3]
trans.p() # params[4]
trans.q() # params[5]
trans.get_matrix() # [[a, b, p], [c, d, q], [0, 0, 1]]
trans.get_rotation_x() # math.atan2(-b, a)
trans.get_rotation_y() # math.atan2(c, d)
trans.get_scale_x() # sqrt(a*a + b*b)
trans.get_scale_y() # sqrt(c*c + d*d)
trans.get_scale() # sqrt((scale_x*scale_x+scale_y*scale_y)*0.5)
trans.get_translation() # [p, q]
trans.params # [a, b, c, d, p, q]

可以将transformrotate应用于一个或多个二维点。旋转意味着p=q=0

trans.transform([0, 0])
trans.transform([[0, 0], [1, 1]])
point = [0, 0]
trans.transform_inv(point)
trans.rotate(point)
trans.rotate_inv(point)

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
从FXML转换为JAVA时,不会加载javafx映像   泛型Java模板调用运行时推断   javascript为什么我的活动没有响应我在样式文件中所做的更改?   如何在HttpClient(java、apache)中自动重定向   java CSV到H2字符编码不匹配   在Java中使用BorderLayout按比例调整用户界面大小   Java中的重定向异常   java RecyclerView搜索过滤器仅过滤一个值   java标准api multiselect与count和distinct不起作用   java为什么我在Solr上做的每一个查询都会占用我10s MB的堆内存?   java如何使用方法解决:锁定帐户三次后?   java如何实现睡眠以显示图像的幻灯片   在Java中,按对象参数对映射<对象,列表<对象>>进行排序   java无法从密钥库读取密钥   java试图将水平recycleview嵌套到垂直recycleview中   认识C++对Web应用开发的重要性   使用共享对象实例化多个Runnable的java含义?   javabeans何时使用JavaBean?