A Generalized Phase Gradient Autofocus Algorithm