A Bayesian approach for the median filter in image processing