Automatically creating a pattern from an image