Multiscale Random Fields with Application to Contour Grouping