Watch this Author's files
Works perfectly. Excellent work!
This is a great idea for a function, but it unfortunately fails in some cases. Matlab has a more robust method built in: bwboundaries.
Does just what I wanted
Thank you for your comment, Shawn; as you mention, Matlab already has a hash table built in: the containers.Map class. They make it difficult to find by never mentioning the term "hash table" in the documentation.
A lovely little program that solved my problem!