views:

345

answers:

1

bwlabel can be used to get disconnected objects in an image:

[L Ne] = bwlabel(image);   

How to calculate the shortest path between two disconnected closed curves?

Is there a practical(not theoretical) solution?

+1  A: 

Suggestion 1

Try extracting the coordinates of the perimeter pixels of the objects you want to connect and use them as nodes in your graph. Then use the A* algorithm to find the shortest paths between each pair between your sets. This effectively solves the all-pairs problem using A* but restricting it to nodes of interest (paths from nodes in one object to the other).

Suggestion 2 (simpler)

Another idea (untested) is to compute the shortest path between the centroid of each blob (regionprops can be used to compute the centroid) and see which perimeter pixel is intersected by the path. Of course, this might work if your centroid is within the blob, but things get messy with non-convex blobs. This reduces the complexity of your algorithm to the number of blobs as opposed to the number of perimeter pixels (which can be huge).

Also, if Suggestion 2 works for you, you can use Floyd-Warshall to compute the shortest paths between all the blobs in the image.

Jacob
Has someone already implemented this?It's not easy for me to roll it myself..
Maybe I'm complicating the problem. Could you post an image? I'd like to see what you mean by "shortest path".
Jacob
You can use the contour of MATLAB's built-in image `coins.png`,basically several disconnected circles.
Do you need to compute the shortest paths between all objects or just two?
Jacob
@Jacob ,I've simplified my question,is there a practical solution?
How to get the contures by `bwlabel` and iterate over each point between different contures?
Are your blobs convex?
Jacob