We present a new method for obtaining local, energy-dependent, single-channel or multichannel optical potentials. The optical potential is obtained by calculating and smoothing a potential that yields the correct scattering matrix for a sequence of truncated interaction-potential matrices. The new method is illustrated by applications to electron-hydrogen-atom scattering in a truncated Hilbert space. The resulting optical potentials accurately reproduce the original close-coupling calculations in the same Hilbert space, and they show clearly the effects of charge polarization and flux absorption. The coordinate dependence and energy dependence of the smoothed optical potentials are compared to models in the literature.