Pattern processing, generation and recognition