1

I want to determine the point where most lines from the image cross. Obviously, there can be more than one such point, but for simplicity I'm trying with just one point for. I was trying with OpenCV built in Kmeans clustering, but this algorithm assumes every point must be clustered, so I get something like this:

output from Kmeans in OpenCV

Obviously it gets much worse when more lines are present as every intersection will offset the center of the cluster What I want to accomplish is removal of all the outliners that come as a result of accidental line crossing here and there which is especially problematic in complex scenes.

I was thinking of DBSCAN but it appears I'd need to implement it myself from scratch since it's not present in OpenCV - I'd prefer not to spend extra time on something that's not a core part of my project and focus on the topic instead of making tools. Is there a library that can do what I need? Alternatively I was considering brutal force in form

for each point in list
    find nearest neighbor 
    if distance > threshold
        label as bad
    if point already has label AND neighbor already has label
        two sets collided, merge them
    else if neighbor already has label 
        assign point.label = neighbor.label
    else
        point.label = new Label
        neighbor.label = point.label
find mass center of each labeled set and replace set with it's center.
Has QUIT--Anony-Mousse
  • 76,138
  • 12
  • 138
  • 194
user3002166
  • 689
  • 9
  • 24
  • It's "outlier", no n. Usually it is not related to lines. And the usual approach for finding geometry like this would be the **hough transform**. There is also a clustering algorithm based on this, called CASH. It might be worth a try. – Has QUIT--Anony-Mousse Apr 15 '17 at 18:25
  • The green lines are the product of Hough transform. The problem is finding the place where most of those lines cross to recover the perspective. With one point perspective it's easy - take biggest cluster, but it's not really a robust approach for 2 or 3 point perspective. I must do the voting for most "sane" vanishing points. I've implemented the DBSCAN for now but it's not perfect. – user3002166 Apr 15 '17 at 19:29
  • Also test DBSCAN variants like OPTICS and HDBSCAN*, and how CASH solves your problem. – Has QUIT--Anony-Mousse Apr 16 '17 at 08:38
  • I can't find HDBSCAN c++ version. So far I've implemented the normal DBSCAN and it seems to solve my problem most of the time. I'll look into CASH when I have the change, thanks – user3002166 Apr 17 '17 at 11:54

1 Answers1

0

You can use Sklearn library in python. It has many other algorithms

http://scikit-learn.org/stable/modules/generated/sklearn.cluster.DBSCAN.html

kcc__
  • 1,638
  • 4
  • 30
  • 59