Self Learning Image Processing Using A Priori Knowledge of Spatial Patterns