Knnsearch but only return values that are fully connected to one another?
1 visualizzazione (ultimi 30 giorni)
Mostra commenti meno recenti
Is there a quick way to filter the output of knnsearch such that only coordinates that would form a cluster are returned? When I refer to a cluster I mean like clusters in an image that would be distiguished by bwlabel or bwconncomp. However, I do not want to use these functions because it would be too slow to put the coordinates into an image and run these functions.
Is there a way do something like knnsearch but set a neighbourhood connectvity such as 26 neighbours?
0 Commenti
Risposte (1)
Walter Roberson
il 12 Mag 2019
The closest you could get to that would be to provide a custom 'Distance' function handle that calculated whether the points belonged to the same cluster and returned inf as the distance if not.
However, I think you would find that the logic that would be necessary to determine whether two points belong to the same cluster would probably not be efficient when repeated over and over again.
You can do things like head straight from the current point towards the other point as long as you can remain in the same cluster, and do the same back towards the first, and then take the two points you get to and start doing simultaneous "hold the left hand to the wall" and "hold the right hand to the wall" boundary tracing and see if you meet up at some point between the two before the left/right for each meet up. If I haven't overlooked something that should be able to figure out if they are in the same cluster. But doing that for every pair of points for every iteration is going to be considerably slower than running a bwlabel.
.. and your mention of 26 neighbours leads me to think maybe you are doing 3D objects, in which case the boundary tracing is going to get considerably messier to figure out iteratively whether two points are in the same cluster.
Vedere anche
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!