Supervised classification techniques are commonly used to assign pixels of multispectral satellite imagery to a predefined set of classes in order to generate or update land use or land cover maps from remote sensed data. These techniques have a limited ability in expressing spatial relationships among pixels. We propose a new contextual approach to address this issue. In particular, we present an integer linear programming formulation which restricts the number of distinct objects in the classified image and we propose a heuristic for the resulting problem. We test it on one generated data set and one real data set.