answered 2014-12-04 07:57:29 -0600
I think that what you are looking for is a shape detection algorithm. If you make a search in the internet I think that you will easily find several approaches. Have a look here to get an idea. I hope that it will help you.