Localization of the wave functions of resonance states through the use of an optical potential