PCL: Filtering Point Cloud given 2 line equations

206 Views Asked by At

Given two line equations in the form y = mx + c all of the points that are not in between of the two lines must be filtered out.

Currently I'm using a pass through filter, which approximately filters out the points. Instead, could this be done more precisely using the two line equations?

1

There are 1 best solutions below

0
On

Suppose you have a line defined by y = mx + c1 and another, defined by y = mx + c2. As you can see, I assume the m coefficient to be identical for both lines, for otherwise the phrase

all of the points that are not in between of the two lines must be filtered out

would be senseless.

Now, sort the lines so that c2 <= c1, that is

if (c1 < c2) std:;swap(c1, c2);

Now you're sure that the c1 line is equivalent to or above the c2 line.

Take any point (xx, yy). Plug xx into the equation of the 1st line, y = m * xx + c1. If the result is smaller than yy, then (xx, yy) lies above the c1 line. You should remove it from the cloud.

Do the same with the c2 line: y = m * xx + c2. If the result is larger than yy, the point (xx, yy) lies below line c2 and should be removed from the set.

In other words, you should keep those and only those points (x, y) that satisfy

  m * x + c1 >= y and m * x + c2 <= y; // assuming c1 >= c2

Example:

Suppose you have y = x + 3 and y = x + 1. Suppose you have a point (2,4). Should you keep it or filter out?

We have c1 = 3, c2 = 1. Let's insert 2 to the first line. y = 1*2 + c1 = 5. 5 >= 4. The first test is passed.

Now the second line. y = 1*2 + 1 = 3. 3 <= 4. The second condition is also satisfied. Conclusion: keep it, in full agreement with t he figure.

Two parallel  lines