add code to calculate mean image and center the image matrix