Recognition of general line patterns with applications to bubble chamber photographs and handprinted characters