# Metrics for Line Segment Similarity

This topic is 3791 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

I am plotting linear regression lines, automatically generated, over a time series. Each line is stored with its r^2 value, the points it uses to determine its regression line, and its equation (in the form y=mx+b). The lines I am plotting are working very well, but I am running into the situation where two lines are plotted over one another. Ideally, I want to determine a metric that will decide which line I should plot. First, I want to determine how 'similar' the lines are. This requires some metric looking at the similarity of their origin points, m and b. m and b can be identical, but if their origins are in sufficiently different locations, they are completely separate lines. The same goes for having a sufficiently close origin, but drastically different m. Then, I need a way, when two lines are 'similar', of choosing which line to keep. This metric should somehow be based on the fit (r^2), the number of points used (better score for more points used). Anyone have any thoughts on the best way of going about it? Not only the actual determination of the metrics, but a fairly speedy algorithm for the culling? Thanks. Corey

##### Share on other sites
Hey

I had a similar problem in the past and I cam up with the following metric:
Instead of considering the line as is, "blow up" the line by some "radius" r to an oriented bounding box in 2d. Now to compare two lines, compute the intersection polygon between these two lines (i used the Sutherland Hodgman algorithm to compute it). The resulting polygon is always convex. This allows you to compute the surface area of this result easily. Now compute the percentage of this area compared to the bigger of the two original areas. The result is a measure for similarity.

Tell me if this worked for you :-)

Frank

Edit: Oh and I am assuming you are actually talking about line _segments_ right? That is finitly long lines in 2d space?

1. 1
2. 2
Rutin
19
3. 3
khawk
15
4. 4
5. 5
A4L
13

• 13
• 26
• 10
• 11
• 44
• ### Forum Statistics

• Total Topics
633743
• Total Posts
3013644
×