Algorithms for Thinning and Rethickening Binary Digital Patterns