(rho/theta) 参数化中定义的两条线的交点 [英] Intersection of two lines defined in (rho/theta ) parameterization

查看:29
本文介绍了(rho/theta) 参数化中定义的两条线的交点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

已经创建了霍夫变换的 C++ 实现,用于检测图像中的线条.找到的线使用 rho、theta 表示,如维基百科所述:

Have created a c++ implementation of the Hough transform for detecting lines in images. Found lines are represented using rho, theta, as described on wikipedia:

参数r代表直线到原点的距离,而θ是向量从原点到这个最近点的角度"

"The parameter r represents the distance between the line and the origin, while θ is the angle of the vector from the origin to this closest point "

如何在 x, y 空间中找到使用 r, θ 描述的两条线的交点?

How can i find the intersection point in x, y space for two lines described using r, θ?

这里是我目前用于转换霍夫空间的函数,供参考:

For reference here are my current functions for converting in and out of hough space:

//get 'r' (length of a line from pole (corner, 0,0, distance from center) perpendicular to a line intersecting point x,y at a given angle) given the point and the angle (in radians)
inline float point2Hough(int x, int y, float theta) {
    return((((float)x)*cosf(theta))+((float)y)*sinf(theta));
}

//get point y for a line at angle theta with a distance from the pole of r intersecting x? bad explanation! >_<
inline float hough2Point(int x, int r, float theta) {
    float y;
    if(theta!=0) {
            y=(-cosf(theta)/sinf(theta))*x+((float)r/sinf(theta));
    } else {
            y=(float)r; //wth theta may == 0?!
    }
    return(y);
}

如果这很明显,请提前抱歉..

sorry in advance if this is something obvious..

推荐答案

查看 维基百科页面, 我看到给定的给定 r, θ 对对应的直线方程是

Looking at the Wikipedia page, I see that the equation of a straight line corresponding to a given given r, θ pair is

r = x cosθ + y sinθ 

因此,如果我理解,给定两对 r1, θ1 和 r2, θ2,要找到交点,您必须为未知数 x,y 求解以下线性 2x2 系统:

Thus, if I understand, given two pairs r1, θ1 and r2, θ2, to find the intersection you must solve for the unknowns x,y the following linear 2x2 system:

x cos θ1 + y sin θ1 = r1
x cos θ2 + y sin θ2 = r2

即 AX = b,其中

that is AX = b, where

A = [cos θ1  sin θ1]   b = |r1|   X = |x|
    [cos θ2  sin θ2]       |r2|       |y|

这篇关于(rho/theta) 参数化中定义的两条线的交点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆