The color gradient in spiral galaxies - Application to M 81