In many tasks of machine vision applications, it is important that recorded colors remain constant, in the real world scene, even under changes of the illuminants and the cameras. Contrary to the human vision system, a machine vision system exhibits inadequate adaptability to the variation of lighting conditions. Automatic white balance control available in commercial cameras is not sufficient to provide reproducible color classification. We address this problem of color constancy on a large image database acquired with varying digital cameras and lighting conditions. A device-independent color representation may be obtained by applying a chromatic adaptation transform, from a calibrated color checker pattern included in the field of view. Instead of using the standard Macbeth color checker, we suggest selecting judicious colors to design a customized pattern from contextual information. A comparative study demonstrates that this approach ensures a stronger constancy of the colors-of-interest before vision control thus enabling a wide variety of applications.