To remove those duplicate lines, there are two things that may help you:
- Double edges may appear that may lead to duplicate lines. A sequence of blurring/dilating the input image would solve these issues.
- Close lines that have almost same slope can be removed by using lower angle resolutions for the
theta
argument of Hough Line method. For example usingπ/180
would result in finding lines that differ only by one degree in their slope. You may use5*π/180
to find lines in 5 degree resolution.
As an example, the following lines are detected by using the raw image and a 1-degree resolution:
After a bit of blurring and using a 3-degree resolution you can get a result like the following:
By changing the threshold, you can get more or less lines.
About fitting curves you pointed in the comments section, yes you can fit curves, but not with hough lines method. You need to find a parametric definition of that shape and try to run the voting procedure in hough transform yourself. The only other shape that opencv helps you to find is circle.
From::https://stackoverflow.com/questions/21121674/more-accurate-houghline-opencv