It's a PS plug-in. Unfortunately not free but it does do a great job at removing gradients in two easy steps.
http://www.rc-astro.com/resources/GradientXTerminator/
It is possible to replicate this with a whole series (15) of PS steps but with my location just a few km's from the city and the skyglow that comes with city living it was worth purchasing.
Peter