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:
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.