We present an efficient method for obtaining the effective single-particle potential for electrons within density functional theory (DFT). In contrast to the independent atom model (IAM) often used to interpret microscopy experiments, our method includes the contributions from charge redistribution and exchange-correlation interactions in a realistic system. The method allows calculation of the effective potential through the widely used pseudopotential formalism instead of the costly all-electron calculations. A transferable and spin-independent core potential for each element is calculated once and for all. The nonlinear exchange-correlation interaction is treated explicitly. This scheme can be readily implemented in pseudopotential DFT codes. We demonstrate the usefulness of our method by calculating the scattering potential and simulating images of nitrogen point defects in graphene for transmission electron microscopy (TEM). The results are in good agreement with experiments.