Atomic-scale contrast mechanism in atomic force microscopy