Aligning shapes for symbol classification and retrieval