Ribbon analysis of contours in natural images