PixInsight LE Tutorial
Flat-Fielding in Film Astrophotography (2/2)

By Carlos Milovic (PTeam)

:: PixInsight Home Page  <Previous

0. Open Images and Set Identifiers

1. Linearize Film Response

2. Divide by the Background Model

3. Restore the Original Aspect of the Image

4. Conclusions


In the previous section we explained the basis of this method. Now we'll show a step-by-step procedure to implement it in the Pleiades Pixinsight LE (version 1.0.1 or later) image processing application.

The same JPEG images used in the preceding section will be employed here, so you can download them to experiment by yourself through the following links:

Original raw image.
Synthetic background model.

Obviously, better results would be obtained by using the original 12-bit TIFF images at full size, but they are too big as to include them here.


0. Open Images and Set Identifiers

We start by opening both images —original and synthetic background model—, and set their identifiers in PixInsight to recognize them more easily. The identifiers will be: "RAW" for the original image and "FLAT" for the background model.

To change the identifier for an image, activate the corresponding image window and selecty les cambiamos sus identificadores para reconocerlas más fácilmente. La imagen original será "RAW" y el pseudo-flat Image > Image Identifier from the main menu. Identifiers will help us to work without the risk of confusion between both images.


1. Linearize Film Response

This is our first processing step, consisting in applying a midtones adjustment function. This can be done in PixInsight with the HistogramsTransform process. Basically, the midtones adjustment procedure implemented in this process is similar to a simple gamma curve.

The output histogram seems virtually empty, but don't worry about that. PixInsight works with 32-bit floating point pixel values so no significant information is actually being lost.


Figure 1— Initial histograms adjustment to linearize film response. Note the Midtones balance parameter.

The exact value used must be found by some trial-error work for each image. In our example we used a midtones balance value of 0.995. Values close to one protect better from saturation of stars.

On Figure 1 we can see the histogram functions for the RAW image, and the parameters applied to both images. This histograms adjustment must be applied to both RAW and FLAT images.

After this initial midtones adjustment, both images look nearly black; only most saturated areas are visible. This can be seen on Figure 2.


Figure 2— The two images after applying an initial histograms adjustment to linearize film response.

As we said above, despite both images seem uniformly black, most data are still there. To verify this, the histogram functions can be explored with enough magnification and resolution (Como se dijo más arriba, pese a que la imagen parezca uniformemente negra, la información todavía está ahí. Para comprobarlo basta con mirar el histograma de alguna de ellas con la suficiente precisión y aumento (Figure 3).


Figure 3— The initial histograms adjustment is a drastic midtones balance transformation, which compresses the information of the image in a limited segment of the available dynamic range. This can ve verified with a magnified representation of the histogram functions.



2. Divide by the Background Model

To perform this division we'll use the PixelMath process. However, just dividing both images doesn't suffice. The resulting image after division must be normalized to adapt pixel values to the sky background model used.

Normalization values can be taken as the median pixel values of the background model for each color channel. To find these values, we activate the background model image, identified as FLAT in our example, and select the Image > Statistics main menu option, or right-click on the FLAT image and select the same option from the context menu. This opens the Statistics window. The median values for each color channel must be used as result factors in PixelMath. The procedure is clearly shown on Figure 4.


Figure 4— The Pixel Math processing window, with the set of parameters specified to divide by the background model (FLAT).

Before entering Pixel Math parameters, we have obtained the median values for each channel of the background model (FLAT) image with the Statistics tool window. These median values, obtained in the normalized real range [0,1], are applied as factors to multiply the corresponding result channels in Pixel Math.

Note that the Rescale result option of Pixel Math must be disabled when applying this method.

Although quite unlikely, the available numerical precision may be insufficient sometimes to specify some parameters with the required accuracy. In these cases the following trick can be used: enter the square root of each median value as a factor for both the target image (the image being corrected) and the final result. This works because each pixel is multiplied twice by the square root of the median value, which is equivalent to just multiplying once by the median valiue. However, more decimal digits can be specified for the square root.

It mask be pointed out that the Rescale result option of Pixel Math must be disabled for this method to work properly.

The PixelMath instance so defined must be applied to the RAW image. It's quite probable that no evident changes be observed after applying it. This is because we are working in a linear tonal space, very different from the original, nonlinear response space. An inverse midtones transform must be applied to restore the original aspect of the image in terms of average brightness.


3. Restore the Original Aspect of the Image

From now on, the background model is no longer needed, so we can close the FLAT image if we wish. Our last processing step consists in applying an inverse transform with respect to the initial midtones balance transform defined in Step 1.

As can be seen by comparing Figures 5 and 1, the output histograms will be quite similar to the histograms of the original image, although they will show somewhat less dispersion of pixel values. This is because we have fixed vignetting or uneven illumination in the image.

The midtones balance value to be used here must be such that added to the previous value used in Step 1, the unity must be obtained. In other words, if X is the previously used midtones balance value and Y is the new value, it is given by:

Y = 1 – X

We recall here that the midtones transformation implemented in HistogramsTransform is not a gamma function strictly, but another quite similar function (rational interpolation).


Figure 5— Final midtones balance adjustment to recover the original aspect of the image. This is the inverse transform to that applied in Step 1.


Figure 6— The image after applying the inverse midtones balance transform shown on Figure 5.

Figure 6 shows the final result. The obtained image must be further rescaled with additional processing in order to maximize dynamic range usage.


4. Conclusions

We have described a new procedure to apply background sky models to astrophotographs obtained on conventional photographic film. By applying these models, a uniform illumination profile is achieved over the whole image in cases where uneven illumination appears as a result of limitations of the optical systems used, or variations due to light pollution, differential atmospheric extinction, and other diverse and concurrent causes.

The method exposed removes the uneven illumination in the image dividing it by a background model after having applied a correction to both images to restore a linear proportion between illumination and exposure time.

Compared to applying background models by simple subtraction, the results of our method show illumination profiles that are more uniform, not just for the sky background, but also for the rest of stellar and nonstellar objects present on the whole images.

To simplify the task somewhat, we have included the process set module file containing the process icons used in this procedure, which have been organized as two ProcessContainer icons, one for each image:

A possible improvement to this method is a previous subtraction of the film base, emulating the bias calibration procedure used for CCD images. However, since flat-field division is made with a highly compressed dynamic range, it is quite probable that this additional correction gives a very marginal improvement.

Future improvements must lead to linearizing functions better adapted to the characteristic response curves of the films used for astrophotography.



:: PixInsight Home Page  <Previous