Home
Exponential Transforms
PIP (Power of Inversed Pixels) and SMI (Screen-Mask-Invert) in PixInsight LE


Tutorial by Carlos Milovic (PTeam)
::Back to PixInsight Page


0. Introduction

1. Preliminary Steps
1.1 Create the Mask
1.2 Select the Inverse Luminance as the Current Mask
1.3 Create the Blurred Image
1.3.1 Blur a Duplicate of the Original Image
1.3.2 Blurring the Duplicate Image with a Wavelet Transform

2. Combine the Blurred and Original Images
2.1 SMI
2.2 PIP

3. Comparison Between the SMI and PIP Methods

4. Conclusions

5. The ExponentialTransform Process in PixInsight Standard



0. Introduction

We call exponential transforms a group of operations between images that tend to increase the contrast in the shadows, avoiding noise amplification and preserving the information in the highlights at the same time. In this tutorial we will take a look at two specific techniques: SMI (Screen-Mask-Invert) and PIP (Power of Inversed Pixels), in their basic forms. In first place, let's review the foundations of both procedures.

Our intention is to increase contrast in the shadows, bringing out the faintest information in the image. For example, suppose we want to reveal very faint nebulosities in a deep sky image. This is very easy to achieve with histograms or curves adjustments; however, by doing so we have to face two serious problems. On one hand, when we enhance features in the shadows, we are enhancing data that is represented by values just a bit over background noise, so noise will usually be increased too. The second problem is that, due to the fact that we are compressing the information in the midtones and highlights, there are many chances for the brightest objects to become saturated.

For the reasons exposed, in general those processes that tend to enhance features represented by low levels should always be applyed selectively, that is, without affecting the highlights, and taking a lot of care to avoid noise amplification.

Applying a process selectively is quite simple in PixInsight: just use a mask. The simplest form of a mask to protect highlight image areas is the inverse of the luminance, which protects bright objects, especially stars. To protect more information we can modify an inverse luminance mask with Histograms, by adjusting the black and white points along with the midtones balance, or by using the Curves process.

Once we have an appropriate mask at hand, we have to find a good way to enhance the desired information without increasing noise. Typically, noise occurs at high spatial frequencies. The simplest strategies for noise removal involve some sort of low-pass filtering. These operations include the median, average, Gaussian, and a lot of suitable filters. However, low-pass filters tend to blur edges, causing some detail loss.

Bearing all that in mind, we'll design exponential transforms as operations between two images (pixel-to-pixel operations): the original working image will provide the required spatial resolution (detail), and a convolved (filtered) version of it, which will be basically noise-free, will preserve roughly the chrominance and overall illumination. As we have explained, exponential operations have to be properly masked to apply them to the shadows only.

We'll review the basic SMI and PIP methods and their implementations in PixInsight LE version 1.0.1 and higher.


1. Preliminary Steps

The following image will serve to show practical implementation examples of the SMI and PIP procedures:


NGC 6888, The Crescent Nebula in Cygnus. Four manually-guided, one-hour exposures, taken on Kodak E200 film pushed +2 through a Meade LX200 12" telescope with Lumicon Giant Easy Guider at f/7 and an IDAS LPS filter. Image by Juan Conejero and Maribel Carracedo, taken from their backyard in July 2003, under heavy light-pollution conditions.

This image has been previously processed with PixInsight Standard 1.0 beta (build 129). The four raw images were matched in brightness and color balance, aligned and averaged. A synthetic background model was created with the DBE process and subtracted to correct vignetting and sky gradient problems. Finally, a curves transform was used to achieve a neutral background. No more processes were applied to enhance the brightness/contrast ratio. The original image is 2048x2048 pixels in size. Our goal is to enhance this image with the SMI and PIP procedures.


1.1 Create the Mask

In this first step we'll create a mask to protect the highlights. The ExtractChannels process is the perfect tool to start with:

In this case, the inverse luminance is the most appropriate mask, since it protects the brightest areas, and does not affect the shadows. We apply ExtractChannels using the CIE L*a*b* color space, unchecking the last two chrominance channels (a* and b*), as shown above. Once we apply it to the image, the luminance will be extracted into a new image windo. After inverting it, by using Image > Invert (or by pressing Ctrl-I), this is the result:

The original SMI procedure (as we'll see in the next section) used just this image as a protective mask. However, we can improve the SMI process (and the rest of exponential transforms) greatly by manipulating this inverse-luminance mask, if we just clip its histogram at the shadows and highlights ends. After such a simple adjustment with the HistogramsTransform process, this is the mask that we'll use throughout the rest of this tutorial:

Besides preserving the stars from growing up too much, this mask protects the brightest nebular regions, avoiding saturation. If we need greater protection for particular areas, the mask can be further modified with curves, or any suitable technique, or it can be combined with other masks.


1.2 Select the Inverse Luminance as the Current Mask

For the previous image to effectively act as a mask, it must be selected as the current active mask for the original image. Having the original image focused, use the Mask > Select Mask (Ctrl-M) main menu option, or click the corresponding tool button on the Mask tool bar. If you haven't changed the default masking behavior in Global Preferences, when you select a mask PixInsight displays it over the original image, to show protected areas. Select Mask > Show Mask to hide the mask, if required.


1.3 Create the Blurred Image

Now we have to duplicate the original image; this duplicate will be low-pass filtered in a subsequent step. We can use the Image > Duplicate option from the main menu:


1.3.1 Blur a Duplicate of the Original Image

At this point we must apply some kind of low-pass filtering process to the duplicate image. The Convolution process that has been implemented in PixInsight Standard is the ideal tool for this task, e.g. to apply a convolution with a synthetic Gaussian function, or with a user-defined kernel filter. Unfortunately, this tool hasn't been included in PixInsight LE, however we have a number of alternatives at hand that will achieve the same practical result.

As a general rule, to blur images (including masks) we may choose between the MedianFilter, SGBNR and ATrousWaveletTransform processes in PixInsight LE. The Median filter doesn't require further explanations. Just remember that it works especially well with impulsional noise (also called salt and pepper noise), like hot and cold pixels, and quite poorly with uniform noise, as film grain.

The SGBNR process can also be used to blur any image or mask. Basically, this process uses a Gaussian-like filter, which is applied to the image using an edge protection algorithm, and optionally through an optional (inverse) luminance mask. If we disable edge protection, we get a "pure" low-pass filter. Because noise typically does not occur at large dimensional scales, the avalaible filter sizes in SGBNR are quite appropriate to our purposes.

In the present example, however, we'll use À Trous Wavelets, mainly to help you become more familiar with this helpful and powerful tool.


1.3.2 Blurring the Duplicate Image with a Wavelet Transform

The à trous discrete wavelet transform algorithm can be used to blur masks or, as in this case, auxiliary images that have to be low-pass filtered. This is done by simply disabling some small-scale wavelet layers. In this way, high-frequency components are effectively removed from the image, which is equivalent to a low-pass filtering process.

In this example, the following ATrousWaveletTransform instance made a good blurring job. Here is a screenshot showing relevant parameters:

The scaling function was the default 3x3 Linear Interpolation function. Note that the Use Luminance option has been disabled, to allow blurring of both the luminance and chrominance components, that is, the three RGB channels. By disabling the first layer and applying a negative bias to the second one, the appropriate small-scale features were removed from the image. Below is a mouseover comparison between the original and the blurred images.


[mouseover: original vs. wavelet-blurred image]

This is just a mild blurring effect. You may want to experiment with different settings, and see how the results vary. Take into account that blurring a SMI or PIP auxiliary image too much or too few, may create halos around bright stars, making them to bloat or grow up excessively. In other words, if we blur in an amount that is similar to the sizes of the bright or dim stars, we may have problems.


2. Combine the Blurred and Original Images

The moment arrived to combine both images to implement an exponential transform. The (modified) inverse luminance mask must be selected and active for the original image.

Two particular functions, which we call PIP and SMI, satisfy our requirements. To help deciding which one to use, we'll implement both functions here, comparing the obtained results. The PixelMath process has been implemented in PixInsight to define and apply any sequence of arithmetic and/or logical operations between images. Hence, PixelMath is the tool of choice to implement exponential transforms.


2.1 SMI

This technique has been first described in the book Photoshop for Astrophotographers, by Jerry Lodriguss. The author explains how to apply this operation through the Screen blending method in Adobe™ Photoshop™. SMI takes its name from the words that resume the steps to follow in Photoshop™: Screen, Mask, Invert.

The Screen blending method is just the inverse of the multiplication of two previously inverted images:

Screen(F,G) = ~(~F × ~G)

where ~ stands for pixel inversion:

~X = 1 — X

In the expressions above, pixel values are supposed in the normalized floating point range [0,1], where 0 is black (no signal) and 1 is white (full signal). This is the native range used by PixInsight LE.

The example below shows how the SMI operation can be very easily implemented with PixelMath in PixInsight LE:

Three inversion operations are required for the screen operation, as we have defined it. Accordingly, the Invert option is active for the target image, for the blurred duplicate, and for the result. Finally, the multiply (MUL) operation has been selected. The Rescale option isn't actually required here, but it can be useful to make use of the entire available dynamic range.

After applying PixelMath, this is the result:


2.2 PIP

PTeam member Carlos Milovic discovered this function while searching for alternatives to the SMI method. The search was carried out to find more controllable exponential functions, since SMI is too aggressive for many deep-sky images.

Like SMI, PIP takes its name from the operations involved, but in this case with the PixelMath process in PixInsight: Power of Inversed Pixels. Here is the required configuration to implement PIP:

PIP is defined as follows:

PIP(F,G) = F^(~G)

where ~ means inversion, as before:

~X = 1 — X

and the ^ symbol stands for the exponentiation (power) operator.In this case, the blured (inverted) image is used as the powering factor.

Again, there is strictly no need to rescale the result, although it can be useful to do so. After applying the PixelMath instance shown above, this is the result:


3. Comparison Between the SMI and PIP Methods

The PIP and SMI functions share many characteristics. Both functions increase the contrast in the shadows, but modifying the corresponding pixel values in different ways. In both cases, faint information can be improved to reach easily perceivable levels. However, the SMI and PIP functions are quite different in their aggressiveness. PIP is a good choice when the background becomes too bright, or if there is an excessive loss of overall contrast. There are also ocasions where the SMI method may lead to unbalanced colors, or color casts. Also, because of the same greater aggressiveness of SMI, there are some ocasions that the colors gets unbalanced, wich in turns is shown as strange or unpleasant casts if any channels dominates.

Here is a comparison between the achieved results for the NGC6888 image used in this tutorial:

Let's theorize a bit now. If we compare both functions, but using the same image as target and operand (in PixelMath), we'll see that both functions are equivalent to the following transfer curves:

As can be seen easily on the figure above, PIP virtually does not change the levels that are typically representing the sky background in most deep-sky astrophotos, that is, under 0.1 in the normalized range. PIP has also a slighter effect throughout the whole dynamic range, when compared to SMI, which makes it a smoother, more controllable function. The functions plotted here for strict comparison purposes are the "pure" SMI and PIP functions; take into account that in practice these functions are always applied through protective masks, so the plotted functions don't correspond to the actual transfer functions implemented with the methods described.

An important fact to be pointed out is that both functions satisfy strict boundary conditions. No information loss is possible due to "out of range" parameters, since both functions pass through the boundaries of the normalized dynamic range. For this reason, if the histogram of the image has been previously adjusted to fit into the available dynamic range, the rescale option of the PixelMath process is not necessary.

Finally, both SMI and PIP functions don't have any local minima or maxima within the normalized range, which ensures the absence of solarization problems. Incorrectly formed masks, however, may yield such undesirable effects.


4. Conclusions

Both PIP and SMI methods improve faint details of deep-sky images without negatively affecting the stars and other bright objects. Background noise is also reduced, since a low-pass filtered version of the image is combined with the original data. By appropriately adjusting the amount of blurring applied to the duplicate image, and carefully tuning the mask, very good results can be achieved with a wide variety of deep-sky astronomical images.

Because any technique or process that we apply to an image has its own side effects, paraphrasing Jerry Lodriguss, this is as closer as we can get to obtain something for nothing. With simple procedures applied to a single image, we have managed to achieve a considerably enhanced, virtually artifact-free result.


5. The ExponentialTransform Process in PixInsight Standard

SMI and PIP have been automatized and grouped into a single process called ExponentialTransform in PixInsight Standard 1.0 Beta.

Thanks to a mathematical reformulation of both functions by Carlos Milovic, and to a clever implementation by the PTeam, the basic algorithm has been considerably enhanced, allowing for the adjustment of the strengh with which both functions are applied. We are currently working on additional improvements that will give full control over the contrast and brightness increments in the shadows, along with a modification of the convolution procedure to avoid artifacts around bright objects. This is a highly flexible implementation, allowing to experiment with the parameter values in an easy and fast way, to provide the user with full control over the final result.

The figure above shows theoretic curves for PIP (red) and SMI (green) functions varying from the first to the fifth order. In blue is shown a new function we are working on. The ExponentialTransform process allows defining orders below one, which yields less aggressive functions than the curves shown. An additional advantage of this process is that we may save the time necessary to create a mask, thanks to the Luminance Mask option.

© Copyright Rob Kantelberg
free hit counters