A probabilistic method for grouping different shape descriptive primitives (i.e., circular arcs and straight segments) extracted from an image is presented. Descriptive primitives (DPs) are organized as nodes of a graph. Geometrical relations between descriptive primitives are represented by links between nodes. Grouping is modelled as the operation of assigning integer values to a set of random variables, each corresponding to a node of the graph. The set of random variables is described as a Markov Random Field with an inhomogeneous neighbourhood system. The energy function of the field can be considered as a computational expression for some Gestalt laws which have been suggested by several psychologist as basic perceptual criteria. Results of an application of the proposed approach to crowding estimation in a surveilled environment are reported.