Flat-fielding Difficult Subjects Using PixInsight LE
Tutorial by Thomas W. Earle

0. Introduction

1. Creating Flats from Extracted Channels

2. Making the RGB Flat

3. Flat-fielding the RAW Image

4. Neutralizing the Background

5. Final Adjustments


0. Introduction
The Orion region is probably one of the more difficult areas to flat-field due to all the faint nebulosity strewn throughout the field of view. Late in February 2006, I composed an image that stretched from the Witch Head Nebula to the Horsehead nebula. While taking the 75 minute exposure, thin cirrus moved through the field of view resulting in the bloating of brighter stars and decreased contrast. The decrease in contrast brought about by the cirrus proved even more challenging due to the "smearing" of fainter nebulosity. I tried to use ABE, but I was unable to remove the central hot spot so I settled on DBE. Through the use of ABE and its processing of each layer separately, I decided to try this advantageous technique using DBE. This article describes the process of building a flat based upon individual layers. I've used this process on two images so far: Orion and the Witch Head and Rosette and the Cone. This article will focus on the difficulties of flat-fielding the Orion and the Witch Head image. Figure 1 shows a low resolution version of the raw image (i.e. original scan) and the post-processed image.

Milky Way Widefield
Figure 1 - The raw, unprocessed image. Mouse over the image to see a low resolution image of the final image.


1. Creating Flats from Extracted Channels
After opening the image in PixInsight LE, you will need to click on the Extract Channels button located on the tool bar. Once the channels have been extracted, you will use DBE on each channel (i.e. R, G, and B). When setting a Default sample radius in the Global tab of the DBE dialog, a generally rule of thumb is to use 0.005 times S (i.e. 0.005*S), where S is the widest pixel dimension of the image. Keep in mind, the resulting value is not set in stone so there will always be exceptions; however, it should be an excellent starting point. Figure 2 shows the Global DBE values used for the Orion and Witch Head image. Once you've selected all your neutral points for the red channel, you will generate a flat. Next, you will need to repeat the process two more times: one for the green channel and one for the blue channel. Figures 3-5 show the points I chose, and the resulting flats from each channel. At present, DBE does not allow you to work on more than one channel at a time.

Figure 2 - Global DBE values used in flat-fielding the image.

Cygnus Region

Figure 3 - DBE points chosen in the Red channel. Mouse over the image to see the generated Red flat.

Figure 4 - DBE points chosen in the Green channel. Mouse over the image to see the generated Green flat.

Figure 5 - DBE points chosen in the Blue channel. Mouse over the image to see the generated Blue flat. As is common, the blue channel generally shows the strongest hot spot.

Figure 6 - PixInsight LE work space after creating the R, G, B flats. Notice, I went through two iterations of DBE before I was satisfied with the resulting flats. You should get into the habit of saving each DBE session so you can see your progress. Keep in mind, DBE is an iterative process.


2. Making the RGB Flat
Once the individual flats have been created, your work space should look similar to Figure 6. The next step is to combine these three flats into a single RGB flat. First, select one of your flats. By doing this, PixInsight LE will automatically create a new image in the same dimensions as the source (i.e. the file you selected). Next, create a new image by clicking on the File menu and selecting New Image.... A dialog box will appear similar to the one in Figure 7. It is important you change the Image parameters to RGB Color. PixInsight LE will automatically default to the sources color space. Since we are currently working with gray scale images, it will default to Gray scale. Once you have set the necessary parameters, you can generate the new image by clicking the Apply button.

It is important to type an Identifier (e.g. rgb_FLAT) for the new image in the Image Parameters section. In addition, it is imperative you click RGB Color.  The Initial Value section can be left alone since it has no bearing on the final outcome. Figure 7 displays how the dialog should appear just before clicking Apply.
Figure 7 - New Image dialog box.

Next, you need to import the individual R, G, B flats into the newly created RGB image. This step is accomplished by clicking the Import Channels button in the tool bar (see Figure 8). In the Channels/Source Images, select your new RGB file as the source image (i.e., the first drop down box). After selecting a source, you need to uncheck Auto Identifiers by clicking on the box to its left. Once Auto Identifiers has been unchecked, select the appropriate flats for each R, G, B drop down list. Finally, click on Apply to create your RGB flat. Figure 8 shows how the dialog should appear before clicking Apply. Figure 9 is the generated flat of the Orion and Witch Head image.
Figure 8 - Import Channels dialog box.

Figure 9 - The generated RGB flat.


3. Flat-fielding the RAW Image
Now that we have a good FLAT, it's time to divide it by the original RAW image.  ABE and PixInsight LE's Pixel Math are the two most common methods. If preserving the original file resolution is a high priority, you should use Pixel Math since ABE's output is limited to 72 ppi. I'm not sure if this is by design or a bug in ABE. Figure 10 shows the result of dividing the original RAW file with the generated FLAT.

Figure 10 - The Orion and Witch Head after flat-fielding.


4. Neutralizing the Background
As is readily apparent, the flat-fielded image has a strong majenta cast. Casts are very easy to correct in PixInsight LE if there is a neutral (i.e., free of nebulosity) area in the field of view. The preferred way to remove a cast is to create a small Preview of a neutral area in PixInsight LE. Looking at several post-processed film and CCD images of this area, I came to the conclusion that the most "neutral" area is about where the Preview01 box is located in Figure 10. The goal is to neutralize this Preview using Histograms. Figure 11 shows a close up view of the Preview.

Figure 11 - Preview chosen to neutralize the color cast in the Orion and Witch Head image.

Figure 12 - Statistics view of the Preview before neutralizing.
We will use the Statistics view to keep track of our Histogram changes. Figure 12 shows our initial Median values. The goal is to match the Median values of Red, Green, and Blue as close as possible. While analyzing these Median values, it's obvious the Red and Blue channels are too high so we must lower them to match the Green channel. Figure 13 shows the initial Histogram values of the Preview. Figures 14-17 show what histogram changes were made to the Red and Blue channels in order to give the Preview a neutral background. Finally, Figure 18 shows the neutralized Preview and its associated Statistics and Histogram view. Note how well the Median values of the Red, Green, and Blue channels match.
Figure 13 - Histogram view before neutralizing the Preview.

Figure 14 - Red channel before neutralization. Figure 16 - Blue channel before neutralization.
Figure 15 - Red channel after neutralization. Figure 17 - Blue channel after neutralization.

Figure 18 - The neutralized Preview and its associated Statistics and Histogram.

Now that we have a neutral preview, it's time to apply this Histogram to the flat-fielded image to remove the color casts. Figure 19 shows the result of neutralizing the background of the Orion and Witch Head image.

Figure 19 - A neutralized, flat-fielded Orion and Witch Head image. Mouse over the image to see the flat-fielded image before neutralizing the background.


5. Final Adjustments
After neutralizing the background, you might still have a very subtle color cast. You can remove this cast using PixInsight LE's SCNR tool. In addition, you should create a few sample points in Photoshop to ensure the colors are correct in a few random nebulas scattered throughout the field of view. I try to sample nebulas which are generally either mostly red or mostly blue and make minor corrections using Curves in Photoshop. Once the color casts have been removed and the "final" color adjustments made, you should gamma-stretch the image to your liking. Of course, you can make all these final corrections/adjustments in PixInsight LE if you like. I'm just a little more familiar with Photoshop when it comes to the final tweaking of an image. One of the final image processing steps is noise reduction. A future tutorial will show the iterative process of reducing both small-scale noise and large-scale noise in a digital image.

Image(s) may not be used or reproduced without written permission from Thomas W. Earle. Copyright © 2006.