This study presents a stochastic framework in which incomplete training data are used to boost the accuracy of segmentation and to optimise segmentation when images under consideration are corrupted by inhomogeneities. The authors propose a semi-supervised maximum a posteriori probability (ssMAP) segmentation method that is able to utilise any amount of training data that are usually insufficient for supervised segmentation. The ssMAP unifies supervised and unsupervised segmentation and takes the two as its special cases. To deal with inhomogeneities, the authors propose to incorporate a bias field into the ssMAP and present an algorithm (referred to as ssMAPe) for simultaneous maximum a posteriori probability (MAP) estimation of the inhomogeneity field and segmentation of brain tissues. Experiments on both simulated and real magnetic resonance (MR) images have shown that ssMAP with only a very small quantity of training data improves the segmentation accuracy substantially (up to 30%) compared to both fully supervised and unsupervised methods. The proposed ssMAPe estimates the inhomogeneity field effectively and further improves the segmentation if the MR images are corrupted by inhomogeneity.