相关疑难解决方法(0)

两组之间的转换

我有对象让我们说模型图像.我想计算模型图像上的对象和目标图像上的对象之间的变换(位移,缩放,旋转).我想假设对象可以被视为2D,因此只应计算2D变换.

首先,我想以手动辅助方式进行操作.用户在模型图像上选择基点,然后在目标图像上选择目标点.点数应由用户定义(但不低于最低2-3点).当点给出不同的信息时,应该对变换进行平均,并且例如由此可以计算匹配的质量.

所以问题是关于计算两组点的变换,但正如我想在图像上做的那样,我添加了图像处理标签.

特别欢迎使用一些代码或伪代码的参考和建议.

有两点是非常容易的问题,只应采用线的旋转,比例和位移,但如何用更多的点来做,并对其进行平均并计算一些质量因素.

目前的解决方案是

void transformFnc(std::vector<PointF> basePoints, std::vector<PointF> targetPoints,
                  PointF& offset, double rotation, double scale)
{
    std::vector<Line> basePointsLines;
    std::vector<Line> targetPointsLines;
    assert(basePoints.size() == targetPoints.size());
    int pointsNumber = basePoints.size();

    for(int i = 0; i < pointsNumber; i++)
    {
         for(int j = i + 1; j < pointsNumber; j++)
         {
             basePointsLines.push_back(Line(basePoints[i], basePoints[j]));
             targetPointsLines.push_back(Line(targetPoints[i], targetPoints[j]));
         }
    }
    std::vector<double> scalesVector;
    std::vector<double> rotationsVector;
    double baseCenterX = 0, baseCenterY = 0, targetCenterX = 0, targetCenterY = 0;
    for(std::vector<Line>::iterator it = basePointsLines.begin(), i = targetPointsLines.begin();
        it …
Run Code Online (Sandbox Code Playgroud)

algorithm geometry image-processing

18
推荐指数
2
解决办法
2万
查看次数

标签 统计

algorithm ×1

geometry ×1

image-processing ×1