Note: This is a preliminary document -- it's really just my initial notes after having developed this idea into an actual process. I will write up more complete documentation, with picture, in the near futre.
Here's an example of an image that has a good signal-to-noise ratio, but is plagued by a severe light-pollution gradient:

Here's what the iamge looks like after applying the technique described on this page to the green layer image:

Sometimes, despite a good dark frame and flat field, your image will still have a gradient in it. This is often due to some form of light pollution or sky glow that varies with distance from the source (moon, a nearby streetlight, a distant city, etc.). Since we often take a flat field using some completely different background (T-shirt, cardboard, ceiling, fence, wall, twilit sky, etc.), any linear gradient in the original data will be preserved after application of a dark frame and a flat field.
To correct such a gradient problem, you need to subtract a gradient at exactly matches the gradient in the image, less about 50 units to allow a little background so that the background is not totally black.
Subtracting such a gradient is easy; creating one is a little complicated. I worked out a technique described here that let's you create the exact right gradient using Photoshop and Maxim DL. Other software might make it a little easier, but I don't know about that other software so I can't tell you! And it looks and sounds much harder than it actually is; once I worked out the formulas and the process, it now takes just a couple of minutes to create the gradient I need.
NOTE: If you own Mira, it includes a command that will calculate the gradient and create a new file that contains the correct gradient for the subtraction. Or it can calculate the gradient correction and apply it via subtraction in a single step. This procedure is for everyone else.
NOTE: Maxim DL does have a Flatten Background command on the Process menu, but it doesn't handle some situations involving linear gradients. For example, an image with a galaxy covering the central third of the field will confuse this feature, leading to bands of lightness and darkness that do nothing to solve the problem.
Photoshop steps:
Since the ideal target value for the background is around 50 units, we want to create a gradient that has a 16-bit value of 2118 at upper left, and 2006 at lower right. There is a net change of 112 units between the two positions. Since Photoshop can't create such a gradient in 16-bit mode, here is how to use the gradient you created in Photoshop to create the exact correct gradient in Maxim DL.
Maxim DL steps:
The formula for converting the existing brightest pixel to the desired brightness (assuming the brightest pixel is currently 3276) is:
Equation 1: (3276 + x)/y = 2118
where x is some value we need to add to all of the existing pixel values in the gradient, and y is some number that we need to divide by to get the desired result. The formula for converting the existing dimmest pixel (which is zero) to the desired level is:
(0 + x)/y = 2006
We can solve for Y as follows:
() + (x/y) = (3276 + x)/y
Multiplying each term by y gives us:
112y + x = 3276 + x
Subtracting x from each side of the equation:
112y = 3276
y = 3276/112
y = 29.25
The generalized formula for finding y, the number we want to divide by, is:
y = <current brightest pixel>/(desired brightest pixel> - <desired dimmest pixel>)
The number we are going to add (x) can now be calculated by dropping y into the original Equation 1:
(3276 + x)/29.25 = 2118
3276 + x = 2118 * 29.25
x = (2118 *
x = 58,675
Thus, if we add 58,675 to every pixel in the gradient, and then divide by 29.25, we will get a gradient with exactly the values we desire. In practice, it is much easier in Maxim DL to perform a subtraction, so divide 29.25 into 1 to get the value by which to multiply: 3.24%.
y = a/(b - c)
where a is the brightest value after Maxim DL step 2; b is the desired brightest value, and c is the desired dimmest value. For this example, this becomes 3276/() or 3276/112, which is 29.25. Now divide 1 by this number and multiple by 100 [(1/29.25) * 100] to get the value to be used for multiplication in pixel math: 3.42%.
x = (b * y) - a
where b is the desired brightest value, y is the result calculated in step 5 above, and a is the existing brightest value after Maxim DL step 2. For this example, this is (2118 * , or 61, which is 58,675.
This subtracts the gradient you created from the problem image, leaving you with a very flat background, and ready for additional processing. Remember that you should already have applied a regular flat field to the image, since this technique can only remove a linear gradient. It cannot help with a gradient that varies in two directions at once, which is typically the kind of problem that a flat field fixes very well.