Matrix of points to suitable Path
Show older comments
I have a 128 by 128 matrix of 0s and 1s, like so

From this I need to generate a single path that starts somewhere at the bottom of the matrix to the highest point of the matrix. So for example the output would be:

I have implementing like a A* path cost flood fill and try to get lowest cost with no luck. Would there be any other methods of doing this? Any recommendations or help would be greatly appreciated !
(The point of this is I need to get a robot to follow the path after converting the pixel coordinates to world coordinates)
2 Comments
Jan
on 19 Oct 2016
Please explain "no luck" with and details. Perhaps you had a simply typo in your code?
trent cooper
on 19 Oct 2016
Edited: trent cooper
on 20 Oct 2016
Answers (2)
Image Analyst
on 20 Oct 2016
0 votes
A* should work. Doesn't look like your code used it though. There are other ways. Like dynamic programming, or the function shortestpath(), etc. Is there a continous path in your dots and just got lost due to subsampling for display? If so, you can use bwdistgeodesic().
2 Comments
trent cooper
on 20 Oct 2016
Image Analyst
on 20 Oct 2016
I don't think A* is the way to go, given the additional information. You want standard tracking. The Computer Vision system Toolbox has lots of demos on tracking things like vehicles and people: http://www.mathworks.com/products/computer-vision/code-examples.html That is what you'd want to do instead.
Walter Roberson
on 20 Oct 2016
0 votes
bwmorph and 'thicken' just enough to join segments together. Then skeletonize.
Or perhaps you could use alpha shapes to enclose the branches, then fill, then skeletonize
Categories
Find more on Sparse Matrices in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!