The amplitude of the induced signal in 3D CdZnTe detector depends on the depth of interaction (DOI). Therefore, calibrating the detector by using DOI correction technology plays a crucial role in improving the energy resolution of the detectors to gamma rays. The current DOI correction method focuses on the single energy gamma rays, and its application to multiple energy gamma-rays are not found. In this study, we propose an improved energy correction algorithm with excellent correction results in the multiple energy gamma-ray detection. In the experiment, the DOI correction factors of a CdZnTe detector under different energies are discussed. The energy resolution and peak height of multiple energy peaks in the energy spectrum are significantly improved by using the segment energy correction method. We also extend the DOI correction method to the gamma detectors used in the Compton imaging, and the influence of this method on the Compton imaging quality is also discussed. For a single 60Co point source, the intrinsic efficiency increases from 6.5‰ to 8.3‰.