The growing use of secondary electron imaging in the scanning electron microscope (SEM) to map dopant distributions has stimulated an increasing interest in the mechanism that gives rise to so-called dopant contrast. In this paper a range of experimental results are used to demonstrate the wide applicability of the technique. These results are then incorporated into a model where, in particular, the effect of the surface barrier and the vacuum level are considered. It is found that the dominant contribution to the contrast mechanism is due to the three-dimensional variation of the vacuum level outside the semiconductor