Recent Comments

Steve Eddins has developed MATLAB and image processing capabilities for MathWorks since 1993. He also coaches development teams on designing programming interfaces for engineers and scientists. Steve coauthored Digital Image Processing Using MATLAB.

In this post in the Exploring shortest paths series, I make things a little more complicated (and interesting) by adding constraints to the shortest path problem. Last
time, I showed this example of finding the shortest paths between the "T" and the sideways "s" in this image:

We can do this by using bwdistgeodesic instead of bwdist in our algorithm. bwdistgeodesic is a new function in the R2011b release of the Image Processing Toolbox. In addition to taking a binary image input that
bwdist takes, it takes another argument that specifies which pixels the paths are allowed to traverse.

In the image above, the white characters are the starting and ending points for the path. The path is not allowed to pass
through the red characters. The gray pixels are all the pixels on any shortest path, and the yellow pixels lie along one particular
shortest path.

Let's have a little fun by using this technique to solve a maze. Here's a test maze (created by The Maze Generator).

"I have a binary image which contains one pixel width skeleton of an image. I have got the skeleton using the bwmorph function.
As you may know basically in this binary image, I have ones on the skeleton and zeros anywhere else. how can I find the shortest
‘quasi-euclidean’ distance between two nonzero elements which are on the skeleton? The path should be on the skeleton itself
too."

The techniques described above can be applied to this path-along-a-skeleton problem. Let's try an example.