Grouping as a Searching Process for Minimum-Energy Configurations of Labelled Random Fields