Strong subsurface attenuation leads to distortion of amplitudes and phases of seismic waves propagating inside the earth. The amplitude and the dispersion losses from attenuation are often compensated for during prestack depth migration. However, most attenuation compensation or -compensation migration algorithms require an estimate of the background model. We have developed a wave-equation gradient optimization method that inverts for the subsurface distribution by minimizing a skeletonized misfit function , where is the sum of the squared differences between the observed and the predicted peak/centroid-frequency shifts of the early arrivals. The gradient is computed by migrating the observed traces weighted by the frequency shift residuals. The background model is perturbed until the predicted and the observed traces have the same peak frequencies or the same centroid frequencies. Numerical tests determined that an improved accuracy of the model by wave-equation tomography leads to a noticeable improvement in migration image quality.