我已经创建了一个C++实现的Hough变换来检测图像中的直线。找到的直线使用rho,theta表示,如维基百科所述:
“参数r表示直线与原点之间的距离,而θ是从原点到最近点的向量的角度”
如何通过使用r和θ描述的两条直线,在x、y空间中找到它们的交点?
以下是我当前用于在Hough空间中进行转换的功能的参考:
//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);
}
提前说对不起,如果这是显而易见的事情...