For the last decade, we have witnessed impressive achievements and the emergence of elaborated registration theories. But the definition of a proper statistical framework for addressing the down-to-earth and fundamental problem of computing population averages in image analysis in presence of unobserved variables has not received so much attention from a more mathematical statistics perspective. This presentation will focus on two examples where statistical generative models and stochastic algorithms can lead to an estimation of such population template. We will first present a careful definition and analysis of well defined statistical generative models based on dense deformable templates for gray level images of deformable objects where the warping variables need to be considered as unobserved random variables. This coherent statistical framework addresses the problem of estimating a template image (photometry) and at the same time some geometrical variability from an image database. We carry out this estimation using two variations of the EM algorithm in a small sample setting : one of them uses a deterministic approximation of the EM, while the other is based on a stochastic formulation (SAEM), coupled with the use of MCMC methods. This approach is then generalized to a mixture of deformable template models to derive a clustering algorithm for the data. We will present some experiments done on handwritten images and 2D medical images. We applied the same methodology to the estimation of a Diffusion Tensor Image (DTI) template where experiments have been done on synthetic and real data. Finally, this approach can also be used for the estimation of Independent Component Analysis (ICA) which will be presented briefly.