Some of the most important phases in the processing of digital images are image segmentation and classification. Contextual algorithms make use of information coming from the pictorial content (called spatial or contextual information) of the data in addition to the spectral properties. A 2-dimensional stochastic model is introduced in this paper, which enables us to combine spatial and spectral information in uniform manner. The Bayesian approach is adopted and, according to this, a pixel is assigned to that class which gives the maximum "a pos-teriori" probability conditioned on not only the observed feature vector of this pixel but also of its neighbours. Depending upon the size of the neighbourhoods and the model to compute the joint probabilities, various (formerly known or new) contextual algorithms can be derived. In order to reduce the computational complexity of the algorithms an iterative approximation is proposed and analysed. These suboptimal algorithms give considerably better results (in comparison with non-contextual ones) while time and storage requirements remain acceptable.