Use C++ rewrite "merge" part of algorithm "LSM", original "LSM" algorithm write by matlab, speed too slow, this algorithm compatible "LSD" and "EDLine" algorithm output pointset to merge lines.
Existing line segment detectors tend to break up perceptually distinct line segments into multiple segments. We propose an algorithm for merging such broken segments to recover the original perceptually accurate line segments. The algorithm proceeds by grouping line segments on the basis of angular and spatial proximity. Then those line segment pairs within each group that satisfy novel, adaptive mergeability criteria are successively merged to form a single line segment. This process is repeated until no more line segments can be merged.
EDM algorithm reference "merge" part of algorithm "LSM".This algorithm takes as input an image and line segments detected by an off-the-shelf line segment detector. The merging pipeline has two main steps. In the first step, we group line segments based on traditional measures of spatial and angular proximity:
- Spatial proximity: Line segments must be spatially close enough to be grouped.
- Angular proximity: Orientation of line segments should not be much different from each other.
Algorithm flow、code and explanation can reference this paper:
(a) Nearby parallel segments thatare perceptually distinct can become merged if adaptive thresholds are not estimated correctly. (b) Sequence of local mergings can eventually lead to a globally incorrect line segment
Include "Merge.h" and contain "Merge.cpp" to your project.
EDLine merge:
// Detection of line segments from the same image
EDLines testEDLines = EDLines(testImg);
// Acquiring line information, i.e. start & end points
vector<LS> lines = testEDLines.getLines();
// Instantiation merge object
Merge ml;
// Get merge line result
vector<LS> result_lines = ml.MergeLine(lines, M_PI / 12, .05);
LSD merge:
// Create LSD output lines end-points with struct "LS"
vector<LS> lines;
// Instantiation merge object
Merge ml;
// Get merge line result
vector<LS> result_lines = ml.MergeLine(lines, M_PI / 12, .05);
- [] Merge line with Ransac algorithm to reduce merge error