Starting with a computational analysis of brightness matching, we develop a novel variational framework able to model perceptual context-driven effects that may be extended to non-physical judgments as well. The most important feature of the variational framework is the description of these phenomena as a suitable balance between contrast and dispersion. The optimal balance is defined through the simultaneous minimization of functionals characterized by two terms in opposition to each other. When the minimum is reached, the equilibrium between contrast and dispersion is attained. To show the flexibility of the proposed framework, we discuss several examples of such functionals in the field of color perception and cognition which show adherence between theoretical predictions and empirical results. With regard to social cognition theories, the simultaneous occurrence of contrast and dispersion conflicts with sequential models, thus supporting the idea of a concurrent presence of both effects in each judgment. The variational framework can serve as a view from above on perceptual and cognitive phenomena that may help in deriving new constraints for disambiguating alternative theories. (C) 2016 Elsevier Inc. All rights reserved.