By Carlos Sonnenstein (PTeam)
Original data acquired by Ignacio Rico
English translation by Oriol Lehmkuhl & Ivette Rodríguez (PTeam)
In this document, a step-by-step, detailed processing example is presented using a DSLR deep-sky image. Our intention has been to compile some postprocessing techniques, including a set of relatively simple procedures such as data format conversion, geometrical transformations and background modeling, along with some advanced algorithms and techniques such as high dynamic range wavelet transforms, and noise reduction, among others.
We have used an excellent DSLR image of M45 acquired by Ignacio Rico, who kindly has given us the image for this work. It is the result of 21 frames of 20 minutes each (at ISO 400), stacked and calibrated with darks taken through a Takahashi Sky 90 telescope + reducer/flattener at f/4.5 and a Canon EOS 400D camera (non-modified).
Figure 1 shows the final result obtained with PixInsight 1.2, using the techniques and tools described in this example.
Figure 1— Final image obtained after postprocessing it with PixInsight 1.2, using the techniques and tools described in this tutorial.
(click on the image to enlarge)
Some of the processes and algorithms that we'll use, such as the High Dynamic Range Wavelet Transform and several aggressive nonlinear transformations, imply complex numerical procedures that require large numerical spaces to avoid degradation of the data due to roundoff and truncation errors. M45 raw data have been saved in 16-bit integer format. Before continuing, we'll convert the image to the 32-bit integer format, which provides a numerical range of 232 discrete values in PixInsight.
Background modelization is a processing technique that allows fixing spurious brightness and color variations, such as uncorrected vignetting and gradients due to light pollution. DynamicBackgroundExtraction (hereafter DBE) provides a tool to carry out these operations in PixInsight with a high level of user interaction.
DBE uses a set of samples defined and placed by the user over the image. Each sample extracts a pixel value for each color channel. From a suitable distribution of a certain number of samples, the modeling algorithm is capable of re-constructing the image background by using a bidimensional interpolation procedure, based on splines.
The DBE interface window contains a set of important parameters that act directly in the process of sky background modeling. Two of these parameters control the sample size (Default sample radius) and number of samples (Samples per row) used in the modeling process. Box sizes too large imply a poor sampling, while too small sizes provoke strong noise dependence.
Another important parameter is Tolerance. This sets the tolerance of the algorithm in order to reject pixels with a certain deviation from the estimated mean sky background, which can be identified by the main peak of the sample distribution in most cases.
On the other hand, Minimum sample weight controls the minimum statistic weight of a sample to be included in the modelization mechanism.
Last but not least, Shadows Relaxation controls the relaxation factor that allows including more dark pixels in the computation of the background model.
Before starting a DBE session, in order to avoid the algorithm sampling zones without true image information, it is important to crop image edges. This procedure is carried out in a dynamic manner on the RGB image by means of the DynamicCrop tool. First, a screen transfer function (STF) is defined, which provides an easy way to see the information contained in the image without altering it.
Now, we can deactivate the screen transfer function and apply a midtones transfer function and shadows clipping with the HistogramTransformation tool. This action allows us to clearly see brightness variation of the background, and accurately define the set of DBE samples that we will apply afterward to the linear raw data.
Figure 4— Adjusting midtones balance and clipping the shadows with HistogramTransformation. (click image to enlarge)
After applying the histogram transformation, it is possible to see the residual vignetting affecting the image, as well as the dimmest nebulae regions of the M45 star cluster.
Now, we can proceed adjusting DBE parameters and creating a set of samples that will be placed throughout the whole image. The rejection of samples located on the darkest pixels at the image corners (caused by vignetting) can be avoided in this case by lowering the Minimum sample weight parameter. Placing samples on stars should be avoided, although the rejection algorithms can get rid of stars and other bright and small objetcs very efficiently.
Figure 5— Distribution of samples and parameters used with DynamicBackgroundExtraction. (click to enlarge)
In order to keep and save the position of the samples and the parameters defined for the sky background modeling, a process icon can be generated to store the whole information previously defined with DBE. This can be done by clicking the small triangular blue icon at the lower left corner of the DBE window and dragging it to any free location of PixInsight's workspace.
Now, we can return to the previous state, where we have the original linear raw data, by means of the Undo command (Ctrl+Z) and thus, apply our process icon to the linear data.
Figure 6— Sample distribution with the same parameters for DBE, but this time applied to the linear raw data. Note the process icon that has allowed us to recover the DBE state that we defined in Figure 5. (click to enlarge)
Once DBE has generated the background model, or pseudo flat-field, it can be subtracted from the raw image. The idea behind this operation is to compensate the illumination profile of the image where needed, in order to correct the sky background brightness and color by subtracting the model from the image. To do this, we define the corresponding mathematical formula in PixelMath, i.e. to subtract the pseudo-flat generated with DBE (M45suma_background in Figure 7) from the main image (M45suma). By rescaling the resulting image (Rescale result checked), we avoid generation of pixel values beyond the limits of the available numeric range, and hence no data truncation can happen.
According to the processing strategy designed for this example, there is at this point no reason to maintain the linearity of the data any longer. Thus, we decide to proceed with a nonlinear transformation of the data, based on a midtones transfer function and a shadows clipping. Now, the true information available in the image is readily visible.
SCNR (Subtractive Chromatic Noise Reduction) is a technique designed specifically for chromatic noise reduction in color deep sky images. The SCNR process pertains to the standard set of noise reduction tools available in PixInsight.
The rationale for SCNR is pretty simple: with the exception of comets and certain regions of some planetary nebulae, deep sky objects and stars are not green, thus green pixels forming part of the cyan tones can be identified as noise. For example, in this image, M45 is a reflection nebula of a deep blue color. As can be seen in Figure 9, nebulae are cyan (a mix of green and blue) due to a large number of isolated green pixels. Assuming that the color is globally well balanced in the image, green pixels are noise and can tus be safely removed.
A common image processing technique to reduce the visual effect of dense star fields, with the goal of achieving a greater visual impact of the main objects, is to apply an erosion filter (also called minimum filter) to the image. The erosion filter is part of PixInsight's set of morphological transformations, and is available in the MorphologicalTransformation tool. It is characterized by reducing the star sizes when the filter is applied with an appropriate structuring element. However, when this kind of filter is used, it can also affect nonstellar objects and the sky background, generating some artifacts. In conclusion, if we want to avoid these adverse effects, we need to isolate the stars and process them separately, hence we need to build a suitable star mask.
With the purpose of generating a star mask, we first calculate the luminance from color data in the sRGB color space, extracting the luminance as a new image (ChannelExtraction process). Now, we can isolate the stars in the luminance by means of wavelet-based transformations.
The ATrousWaveletTransform process in PixInsight allows, among many other functions, to perform a multiscale analysis based on the decomposition of the image into different layers, each of them containing the existing information within a prescribed range of dimensional scales. In this way, the smallest scales include the smallest image structures, as defined by the scaling function used, while the largest scales contain the largest image structures. Using this tool, we can isolate all image structures as a function of their characteristic sizes.
If we inspect the different structures from the image decomposition into layers, we conclude that the smallest stars are present mainly in the two-pixel scale, while the largest and brightest stars, as the main stars of M45, are contained in the 128-pixel scale (the eighth layer in a dyadic decomposition sequence). Unfortunately, a perfect isolation of the objects is not always possible. Nebulae and stars can be present in the same layers, but fortunately there are other mechanisms that can be helpful in order to isolate the stars completely.
After analyzing the wavelet layers, we have decided to remove the first layer, since it only contains noise and no significant data. On the other hand, scales above the eighth layer have no contribution to the stars that we want to include in the mask. Starting from the eighth layer large-scale structures, as the nebulosity surrounding the brightest stars of the cluster, are also present. Thus, all layers higher than 128 pixels (gathered as the residual layer in the example of Figure 10) will be removed.
A usual effect of wavelet transformations applied to build star masks is a lack of contrast in the mask. Thus, we have decided to increase the weight of the active layers. Finally, in order to generate a mask that is independent on the noise, we have used the k-sigma noise reduction parameters of ATrousWaveletTransform, adjusting denoising at its maximum intensity (Amount), and removing with the Threshold parameter the residual noise in the mask.
After this transformation, there still remain some structures that are not stars. In order to make a perfect mask we use a simple but effective method: binarization. We know that the large-scale structures still present in the mask are chiefly composed of gray pixels, which facilitates removing them. The Binarize process (Process > IntensityTransformations > Binarize) in PixInsight transforms all pixels in the image to either pure black (zero) or pure white (one). Binarize's threshold parameter also allows the perfect isolation of the stars in the mask by fine tuning the structure withdrawn.
After the binarizing process, the edges of the objects in the mask are still sharp, so a slight convolution should be applied to the mask. Among the different ways of obtaining an image blurring effect in PixInsight, there is ATrousWaveletTransform.
However, this time we have chosen a different but also effective way. We have applied to the mask the low-pass filter implemented in the noise reduction process ACDNR. For an effective convolution, we deactivate the edge protection mechanism of ACDNR and adjust the smoothness parameters of the filter. We will comment the performance of ACDNR for "normal" noise reduction tasks later.
Finally, we enable the mask for the RGB image and apply the erosion filter (MorphologicalTransformation). Among the different configuration options for this filter, we have used a circular structure and a 5x5 kernel. By applying some filtering iterations with moderate intensity it's possible to achieve a more controlled effect for the stars.
The main purpose of reducing the visual impact generated by the large amount of stars in the field has been successfully reached. However, we have lost contrast in the dimmest stars. In order to minimize this problem, we have again given a boost to contrast in the stars through the mask by means of a wavelet transformation, increasing the weight of the two-pixel layer. The chosen scaling function must be capable of separating small scale components in an effective manner, and at the same time avoiding stars growth in size.
While other techniques such as DDP (Digital Development Processing) can be useful, we prefer more sophisticated tools and implementations, such as HDRWaveletTransform in PixInsight. This tool has been designed specifically for controlling the dynamic ranges of images.
The HDRWaveletTransform algorithm works really well in many cases with its default parameters. However, for this example we have modified the scaling function and the number of wavelet layers, with amazing results. Nebular structures in the M45 star cluster are now much better enhanced.
Figure 15— Result after applying the HDRWaveletTransform algorithm in PixInsight. (click to enlarge)
A color saturation boost can be carried out by different ways in PixInsight; for example with a midtones transformation, or by applying curves in different color spaces. Our recommendation is to modify color saturation working in the HSVL or CIE L*c*h* color spaces, since they perform a much more accurate isolation of the chrominance.
In this example we have increased color saturation by modifying the c* component of the CIE L*c*h* color space. In this color space, an aggressive increase in saturation can be achieved without causing any deviations in color hue. However, independently of the color space used, the higher the increasing in color saturation, the higher the resulting noise in the chrominance.
We have chosen the LRGBCombination process in PixInsight, not only because it is an excellent tool for LRGB image combination, but because it allows a significant boost in color saturation by means of a midtones transfer function applied to the CIE c* component, while at the same time it can reduce chrominance noise efficiently (in the CIE L*a*b* space).
Also we like to preserve a neutral color of pixels in the sky background, so we have built a mask from the luminance to protect it. In this mask, background sky pixels must be black, while pixels in stars and other objects are almost white.
Now, we extract again the luminance from the RGB data, and by means of HistogramTransformation we carry out a midtones transformation and a shadows clipping.
Now, a slight blurring will be applied to the mask with ATrousWaveletTransform, by removing all wavelets layers under six pixels (using a linear scaling sequence). This can be seen on Figure 17.
Before applying a color saturation enhancement, it is useful to verify background protection through the mask, by activating it on the RGB image. This can be done with the Mask > Show Mask command.
Figure 18— Verifying mask protection with the Mask > Show Mask command. With the mask shown, protected pixels are darkened on the screen rendition of the image. (click to enlarge)
Finally, we have applied a color saturation enhancement with LRGBCombination. To do this, we have deactivated the R, G and B channels (as they play no role in this process), have checked the "L" box, and have selected the luminance of our RGB image (identified as Luminance_RGB on Figure 19). Then we have defined the midtones transfer function in the saturation component, and at the same time we have adjusted chrominance noise reduction parameters.
Figure 19— Color saturation and chrominance noise reduction with LRGBCombination. (click to enlarge)
ACDNR performs luminance/chrominance separations, as do all standard PixInsight processes, by means of colorimetrically-defined RGB working spaces. These color spaces are characterized, among other parameters, by luminance coefficients.
Luminance coefficients define the relative weights of individual RGB components for the calculation of pixel luminance values. In the example shown on this figure, a uniform RGB working space is being defined by assigning the same value to the three luminance coefficients. A uniform color space provides better luminance/chrominance separations for deep-sky images, when compared to the default sRGB space. To learn more about this important topic, you can read a specific document, pertaining to the official PixInsight LE documentation.
ACDNR (Adaptive Contrast-Driven Noise Reduction), as its name suggests, reduces the noise in the image as a function of contrast variations. This algorithm includes two devices: a low-pass filter and an edge protection mechanism, including different methods to achieve robustness in the process. These methods allow ACDNR to distinguish noise structures from significant structures in an efficient manner.
In addition, ACDNR includes a built-in masking function to filter the noise reduction work depending of mask construction parameters. In fact, the performance of the built-in mask is the same as in any other inverted luminance mask in PixInsight, but with this function the flexibility of ACDNR is greatly improved. This characteristic is very useful when we want to protect zones with high signal-to-noise ratios, while a strong noise reduction in zones with less signal is applied, as for example in background sky regions.
Previously, we have reduced the chrominance noise and, at the same time, we have boosted color saturation. However, there is still noise in the luminance. In color images, as in our example, ACDNR offers two independent sets of parameters: one for luminance and the other one for the chrominance.
To apply noise reduction exclusively to the luminance , chrominance ACDNR parameters must be deactivated, and only the luminance parameters must be used. To this purpose, the Apply check box must be unchecked on the Chrominance section. Before adjusting the filter's StdDev parameter, it is a good idea to take into account the kind of noise present in the image and its distribution. By selecting Image > Display > Luminance (Ctrl+Shift+L), the luminance of the image is represented as a grayscale image on the screen. To return to the normal RGB composite rendition, select Image > Display > RGB/K (or press Ctrl+Shift+0).
As the noise is present almost exclusivelly at small scales in this image, we have adjusted a moderate value for StdDev and also for filtering intensity, together with the number of iterations. In the edge protection section of ACDNR, we have decided to keep the default parameters, except for Threshold, which has been adjusted to obtain the best results with our image.
Finally, we have adjusted also the inverted luminance mask in ACDNR with the preview option activated, filtering the noise reduction process and defining the protection of the zones with high signal/noise ratio (dark pixels in the mask).
The final adjustment is a slight increase in the midtones, also with HistogramTransformation, in order to highlight the dimmest nebulosities surrounding M45. Further image improvements are also possible, such as a contrast boost applied to the brightest and darkest large-scale image structures. However, these things are beyond the scope of this document.