speedup mean image calculation