Improving line extraction from HoughLinesP
Hi,
I am using HoughLinesP
to extract lines from grayscale image.
Below is my psudo code.
threshold(img_tmp,bin_img,30,255,cv::THRESH_BINARY);
Canny(bin_img, canny_img, 50, 255, 3);
vector<Vec4i> tmp_lines;
HoughLinesP(canny_img,tmp_lines, 1, CV_PI/360,10, 10, 1);
As seen in below image single edge (i.e single line in image) is returning more than one line. 16,22 and 0,28 and 10,11 and 23,18,24 lines correspond to single line.
How can i get single line for single edge, any suggestions ?
Input image:
Extracted lines
Zoomed image
thanks.
You should increase the last parameter: "maxLineGap – Maximum allowed gap between points on the same line to link them."
i tried it and didnt solve, here the issue i guess due to width of the edge
I see that you are using a large angular accumulator (CV_PI/360=0.5°). That means that if there is a minimal difference between the line directions, they will be considered as separate lines. try to use different values for this parameter ( as your lines are a bit "noisy", you can go up to CV_PI/36 = 5°). It will eventually detect more lines, too.
i tried with 1° and 5° but the result was same.