我有一个带有细线图的简单二进制图像,其目标是从下面的图像创建一个单独的边缘/线的矢量-总体目标是创建一个邻接图(数据结构)。
到目前为止,我已经使用cv::HoughLinesP()
给出了一些但不是全部的边缘。我可以通过迭代它们存储在其中的矢量来绘制这些边缘/线条。
// perform probabilistic hough line extraction
std::vector<cv::Vec4i> vec_lines;
cv::HoughLinesP(
img_edges, // input img (from edge detector)
vec_lines, // ouput vector of [x_start, y_start, x_end, y_end] for each line
1, // resolution of parameter rho in pixels
CV_PI/180, // resolution of theta in radians
10, // minimum number of intersections to “detect” a line
5, // minimum number of points that can form a line
0 // maximum gap between two points to be considered in the same line
);
// draw lines
for (const auto& l : vec_lines)
cv::line(img_out, cv::Point(l[0], l[1]), cv::Point(l[2], l[3]), cv::Scalar(255, 0, 255), 1, 8);
结果如下:
参数不足还是有更好的方法?