PixInsight : Dynamic narrowband combinations with PixelMath

Introduction

Channel combining is by far my favorite step in narrowband processing. It’s one of those steps where you can fully express your creativity and make your image look like no other. In this tutorial, I’ll explain how to do so with the most powerful tool in PixInsight : PixelMath.

Linear or non-linear blending ?

Should you blend linear or non-linear images ? There are two schools of thoughts on this subject. I personally stretch my channels before combining them as it allows me to have greater control over the final image, but I encourage you to read this article from Jon Rista and try for yourself. In this tutorial I’ll be working with stretched images. If you decide to do the same, make sure the background values of your narrowband channels are approximately the same.

Basic combinations

Traditional blends such as SHO, HOO, or HSO are pretty straightforward : each RGB channel is assigned to one of the narrowband channels.

You might be disappointed that the colors don’t look quite like Hubble’s classic gold and cyan. The more advanced combinations that involve mixing the narrowband channels can get you close. Here’s an example :

But if you’re like me, you’re probably still not satisfied.

Dynamic combinations

You might be wondering why I added the word “dynamic” in the title. Let me first explain what a non-dynamic combination is. The last combination mentioned above is what I call a “static” combination : the multiplying factors applied to the narrowband channels are numbers. In the expression for the red channel for example, .6*SII + .4*Ha, the multiplying factors are 0.6 and 0.4. Note that the sum of the multiplying factors is always equal to 1 (it has to be, to avoid clipping the channel).

“How can these multiplying factors not be numbers ?” you might ask. We’ll get there, but first you need to know one thing about manipulating images with PixelMath : each pixel of a monochrome image has a corresponding value in the normalized range [0,1]. Consequently, when you enter a number between 0 and 1 in PixelMath, you’re also entering an image. For example, 0 produces a black image and 1 produces a white image.

Now let’s look at static combinations differently. If you view the multiplying factors as images and not as simple numbers, here’s what the 0.6 multiplying factor look like :

You get a uniform gray image. I can now explain what I mean by “dynamic” combinations : the multiplying factors of a dynamic combination are non-uniform images. I’ll refer to those as “dynamic factors”. The dynamic aspect comes from the fact that, in terms of numbers, there is not only one global factor applied to the whole image, but rather a different factor for each pixel.

The sum of the combination factors still has to be 1, a white image if you prefer. If there are only two factors and the first is called X, you can define the second by using the operator “~”. ~X  will return 1 – X, or inverts the image in other terms.

Here’s a simple example of a dynamic combination :

To put it simply, the left part of the image is HOO while the right part is SSO.

This is of course a bad example as the image f  (the dynamic factor) was made in Photoshop and isn’t based on any scientific data. Instead, I recommend you to base your dynamic factors on your own narrowband data.

Creating a dynamic factor

This is the part where you need your images to be stretched. If you still want to combine your channels in the linear phase, you will need to work with stretched copies from now on. I’ll start with an example of a dynamic factor I’ve made for a custom bicolor combination :

The factor here is Ha*OIII with a PIP transformation (Power of Inverted Pixels) applied to it. Of course, you don’t have to use PixelMath for everything. In that case you could also create the image Ha*OIII and then apply whatever transformation you want using CurvesTransformation instead of the PIP transformation.

Ha*OIII is a good representation of where both the OIII and the Ha signals are strong. Here, I used it to create a synthetic green channel.

Each pixel of the green channel is the result of a custom blend of Ha and OIII (for example : 0.8*OIII + 0.2*Ha) where the factors (0.8 and 0.2) are determined by the intensity of the corresponding pixel in the image. In other words, the areas where f  is black (where either Ha or OIII is weak) are straight HOO while the areas where f  is strong (where both Ha and OIII are strong) are closer to HHO.

Here’s a more complex example of a dynamic combination that involves SII data :

Here, the factor is simply a boosted (and stretched!) copy of the OIII image. I will now try to explain what I did for the red channel, since the green channel is very similar to the one presented earlier. The colors I had in mind were a strong red where there is Ha and a strong blue where there is OIII. Of course, there’s Ha everywhere so a simple combination where Ha is mapped to red and OIII to blue would produce purple in the OIII regions. This lead me to this expression for the red channel : f*SII + ~f*Ha, which means in simpler terms “SII where OIII is strong and Ha where OIII is weak”. SII being weaker than Ha, especially in the regions where OIII is strong, implies that the stronger the OIII signal is, the weaker the red channel is. This is how I managed to get a strong blue instead of the typical purple produced by a standard HSO combination.

Some universal expressions

Here’s two compact expressions I’ve made that seem to work well on most targets. You don’t need to create the dynamic factors for those ones since they’re already contained in the expressions. You will note that the second one is exactly the same as the one I used for the bicolor example.

Sii/Ha/Oiii :

  • R = (Oiii^~Oiii)*Sii + ~(Oiii^~Oiii)*Ha
  • G = ((Oiii*Ha)^~(Oiii*Ha))*Ha + ~((Oiii*Ha)^~(Oiii*Ha))*Oiii
  • B = Oiii

Ha/Oiii :

  • R = Ha
  • G = ((Oiii*Ha)^~(Oiii*Ha))*Ha + ~((Oiii*Ha)^~(Oiii*Ha))*Oiii
  • B = Oiii

Please credit my website if you end up using one of those expressions! 

Extra : luminance layer and color adjustments

Keep in mind that the resulting image is often far from being the final image. I recommend you to create a separate luminance layer, as it can greatly improve your image (but that’s the subject of another tutorial). Here’s the same image of IC1396 (& friends) with a luminance layer applied to it :

Curves adjustments (Hue in particular) are also almost necessary as fine adjustments with PixelMath can be quite tricky.

Dealing with star color can also be done by using CurvesTransformation with a star mask. If your stars are purple you can also invert the image, apply SCNR (green) with a star mask, and then invert the image again.

This concludes my tutorial on how to do dynamic narrowband combinations with PixelMath. Feel free to contact me on Discord (ForaxX#0335) or Instagram (@thecoldestnights) if you have any questions/comments/suggestions regarding this article.

5 Replies to “PixInsight : Dynamic narrowband combinations with PixelMath”

  1. This very interesting work. Thanks for sharing. Could you point me to some background information on PIP? Something that goes into what it is intended to accomplish and how that goal is accomplished…I guess something technical in bent. Thanks

    1. Thanks! Here’s a video from Adam Block explaining the different exponential transformations : https://youtu.be/ZmML4UekFMg. TLDR : it is a specific transformation that you could achieve with CurvesTransformation. The details are honestly not important but if you want to understand what you’re doing I’d recommend creating the dynamic factor f separately using CurvesTransformation (as described in the tutorial) instead of using the all-in-one PixelMath expressions.

Leave a Reply

Your email address will not be published. Required fields are marked *