Gradient Removal with Picture Window Pro

I purchaseed Picture Window Pro 3.1 after seeing a large number of people on APML mention using it for image processing. I've only been using a couple of weeks at the time of this writing, but so far I am quite happy with it. Picture Window Pro is happy to do a lot of tings with 48-bit images that Photoshop does grudgingly (if at all). It also seems to run faster as it should: it is nowhere near as feature rich as Photoshop as it does not need all of the graphics arts tools.

Here is a short version of how I processed my constellation portrait of Hercules. Some of the steps here involved trial-and-error; I'll save you tedium of reading through that, but will point out where I had to try more than once.

Step Zero: The Raw Image

Obviously, the starting point is the raw image. In my case, I scanned my slide using VueScan for Linux and saved the raw image. I purchased VueScan in part because I heard good things about it and in part because I wanted a comparison of using it instead of one of the SANE tools (e.g., xsane, scanimage, xscanimage, etc.). I've concluded that I could have happily continued using SANE without any problems. More on that elsewhere.

Raw scan of Hercules slide
Object Hercules
Comments This is the raw scan data (scaled down and converted to JPEG). Note the mild gradient toward the west (lower right).

Step One: Synthetic Sky Glow Maps

Hercules was high enough in the sky that I really didn't expect to have any problems with sky glow, yet the film clearly shows some glow on the western side. Fortunately, Hercules contains no significant nebulosity nor does the Milky Way appear in the field of view. This makes it possible to use the simplest of all possible gradient removal methods, a wide Gaussian blur (Transformation -> Blur). I used a 100-pixel radius Gaussian blur which completely obliterates any stars.

Why do we do this? Well, in some sense this step is like a dark frame that CCD imagers take. The question is, in the absence of any stars, what does the image look like? The problem is that there is light reaching the camera that has nothing to do with the stars and which is not internal (like CCD dark current).

Gaussian blur of Hercules showing gradient due to sky glow
Object Hercules
Comments Image of Hercules after 100-pixel radius Gaussian blur. Nothing is left except a mild gradient caused by local light pollution.

Step Two: Gradient Removal

Once you've created a gradient using the Gaussian Blur, it gets removed by using the Composition tool (Tranformation -> Composition). From this tool, you can select which two images are to be combined and how. Subtract the blurred image from the original. I chose to subtract 90% of the blurred image. I knew I wanted to subtract less than 100%, but how much less was a matter of trial and error. I started out subtracting only 50%, but by the time I finished my latter steps (i.e., a midtone stretch) the gradient from the sky glow had reappeared.

Hercules image after subtracting the gradient
Object Hercules
Comments Image of Hercules after subtracting the gradient created by the 100-pixel radius Gaussian blur.

Note that the image appears somewhat dark. Subtracting out the sky glow results in darkening the entire image but that's okay, we can "fix" that up by some contrast stretching later.

Step Three: Contrast/Level Adjustment

Here I chose to use Picture Window Pro's Transformation -> Gray -> Levels and Color menu as the quick way to get the effect I wanted. You should be able to do the same thing by adjusting the curves. From the Levels and Color menu, I boosted the midtones by about 65% but made no adjustments to the color saturation. Quite frankly, it already looks pretty colorful to me. The 65% figure was a matter of trial and error and you could pick something different based on taste.

Hercules image midtone stretch.
Object Hercules
Comments Image of Hercules after boosting the midtones by 65%.

Step Four: Unsharp Mask

Quite frankly, at this image scale, the effect is irrelevant. An unsharp mask should really be done at the image scale where you plan on displaying the final results. I.e., if you unsharp the original image (scanned at 2400dpi) and then reduce the image by a factor of 10-15 (like this one), you've wasted your time. Of course, you might not have spent much time, but the point is that the unsharp mask is a small effect at this image scale. If you plan on making a print at full scale, then the step is worthwhile.

In my case, an unsharp mask with a radius of 2 and boost of 100% did a nice job of tightening up the image. Radii larger than 3 resulted in stars starting to spread out again. Since the result had no effect at the resolution used on this page, I've skipped the image. As an FYI, you should really do the unsharp mask at the display resolution since a rescaling destroys the results.

Hercules, unsharp mask
Object Hercules
Comments Image after mild unsharp mask.

Step Five: What did I do?

I have no idea. I did an extra step before saving the image, but I don't know what it was. There is very little change to the final result, so it was obviously not very important. And it definitely does not show up at the resolution of these images.


Below are the images in sequence showing the progression. Note that once the midtone-stretch is complete, there is no significant change to the image at this resolution. In fact, except for the full scale image, the effects of the unsharp mask are insignificant. I said it earlier but I'll say it again: you should really do the unsharp mask at the display resolution since a rescaling destroys the results.

Raw scan of Hercules slideGaussian blur of Hercules showing gradient due to sky glowHercules image after subtracting the gradient
Hercules image midtone stretch.Hercules, unsharp maskHercules, unknown modification, final result
Object Hercules
Comments Image processing sequence. From top left: raw image, gaussian blur (background), background subtracted, midtone stretch, unsharp mask, unknown final modification.

SANE vs VueScan

SANE, Scanner Access Now Easy, is the Linux framework for interfacing with scanners. There are a number of tools for doing the actual scanning. The most primitive one is called scanimage. It is a command-line tool which, for my purposes, is perfect. In its default mode it yields a raw scan image with no corrections. Since this is what you generally want for processing your images, you don't really need to buy VueScan. VueScan will take care of some things for you that scanimage won't such as compensating for film base color. For slides this is irrelevant, but for negatives it's a nice feature, at least for normal daytime shots. Since astrophotos are likely to need color balance changes anyway, there is little motivation to do a partial job in the scan step.

However, some of my contentment may be due to ignorance. In particular, the documentation of SANE's Epson driver and that of VueScan leave a bit to be desired. It is unclear to me how much control over the scanner I have while it is still doing the scanning in analog mode.

I mentioned that scanimage is a command-line tool. After a bit of work, I put together a shell script which will automatically scan specific locations on the strip holder. I can now run that, launch it into the background, log out and go away while the scanning takes place. VueScan has a batch mode which is similar but requires you to keep the GUI up and running. VueScan also seems to keep the scanner active between scans even when it is idle.

The short of it is that VueScan doesn't really give me anything that scanimage doesn't for astrophotography. However, if you are not comfortable with the command-line on Linux, VueScan gives a nice interface that does make scanning very easy.