Abstract. Deformable template models are valuable tools in medical image segmentation. Current methods elegantly incorporate global shape and appearance, but can not cope with localized appearance variations and rely on an assumption of Gaussian gray value distribution. Furthermore, initialization near the optimal solution is required. We propose a maximum likelihood shape inference that is based on pixel classification, so that local and non-linear intensity variations are dealt with naturally, while a global shape model ensures a consistent segmentation. Optimization by stochastic sampling removes the need for accurate initialization. The method is demonstrated on three different medical image segmentation problems: vertebra segmentation in spine radiographs, lung field segmentation in thorax X rays, and delineation of the myocardium of the left ventricle in MRI slices. Accurate results were obtained in all tasks.