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

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

问题描述

创建了用于检测图像中线条的Hough变换的c ++实现。发现的线条用维基百科上描述的rho,theta来表示:


$ b


参数r表示线条与原点之间的距离,而θ是从原点到这个最近点的矢量的角度

如何找到x,y中的交点用r,θ来描述两行的空间?



这里是我目前用于转换进出hough空间的函数:

  //得到'r'(与极点相交的一条线(角,0,0,距离中心的距离)的一条线的长度) (((float)x)* cosf(theta))给定点和角度(以弧度表示)
内联浮点point2Hough(int x,int y,float theta){
return +((浮点)Y)* SINF(THETA));
}

//在角度theta上得到点y的距离与r的相交点x的距离?糟糕的解释! > _<
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; // w the theta may == 0 ?!
}
return(y);
}

如果这是明显的事情,请提前抱歉..

解决方案

查看维基百科页面<我看到对应于给定的给定的r,θ对的直线的方程为:bb
$ b

 r = xcosθ+ ysinθ pre> 

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

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

即AX = b,其中

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


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:

"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 "

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..

解决方案

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θ 

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

that is AX = b, where

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

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

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