niro
niro

Reputation: 977

How to compute overlap between nearly parallel two line segments

I have equally oriented (but not exactly parallel) 2D line segments. I want to find out a line segment which is given maximum overlap with a given line segment. I think scalars can be used to compute this effectively, but my geometry is too poor to figure out this. for example, in the below figure; dark line is assumed as the given line and red highlighted line segment is given the maximum coverage (or longest overlap, not sure whether my terminology is correct) when compared to other line segments.

My objective is to find the best line which represents the dark line from the other line segment sets.

what i want to find is any line which has maximum coverage to a given line. that mean, i want to avoid line segments whose starts and ends are out of the ends of the given line segment. also, when many lines give their maximum coverage for the given line, then i want to avoid shorter line and need a long one. idea is to find another line which we can consider instead of that given line segment

helps are highly appreciated as later i want to implement this in programming environment. thanks

example 1 example

enter image description here example2

to say what i meant 'coverage', i will say in above figure: the projected blue line completely lay within the dark black line. but it is too short. But, large portion of the red line (projected line) lay within the black line though some part of the red line go out. green line is completely out of the black line. so, i can say red line give maximum coverage with black line..(does my idea correct?)

Upvotes: 2

Views: 1458

Answers (2)

maxim1000
maxim1000

Reputation: 6365

  1. Project ends of a candidate segment onto the target segment.
  2. Calculate distance between projections.
  3. [optionally] Multiply by cos of angle between the segments.

Note about #1: in this context projection on a segment means the closest point lying on that segment. One of ways is:

  • project a point on infinite line going through the segment
  • if the projection is inside of the segment - take it
  • if the projection is outside of the segment - take the closest segment end

Upvotes: 4

tomriddle_1234
tomriddle_1234

Reputation: 3213

I don't know your question are on graphics processing or computational functions.

But for graphics, this question belongs to computer vision subject, what you want is maybe the Hough Line Transform algorithm.

However, if you question is simpler than this, what you want maybe the SAD algorithm

Upvotes: 0

Related Questions