Wertheimer's theory suggests a general perception law according to which objects having a quality in common get perceptually grouped. The Helmholtz principle is a quantitative version of this general grouping law. It states that a grouping is perceptually "meaningful" if its number of occurrences would be very small in a random situation: geometric structures are then characterized as large deviations from randomness. In two previous works, we have applied this principle to the detection of orientation alignments and boundaries in a digital image. In this paper, we show that the method is fully general and can be extended to a grouping by any quality. We treat as an illustration the alignments of objects, their grouping by color and by size, and the vicinity gestalt (clusters). Collaboration of the gestalt grouping laws and their pyramidal structure are illustrated in a case study.