Processing Duo-Narrowband Images With Pixel Math In Siril

Pixel Math In Siril

Preparing Your Images
Duo-Narrowband Images
Pre-Processing Ha and Oiii
Background Extraction
Histogram Transformation
Working With Oiii Image
Processing Images With Pixel Math
Applying Pixel Math Expressions
Using Parameters

Preparing Your Images For Pixel Math Operations

When processing duo-narrowband images with Pixel Math in Siril, it is important to go through some simple pre-processing steps to ensure that the images have the same (or very close) intensity levels so that they will be complementary during Pixel Math, as well as with RGB Compositing processes. Images of disparate intensity levels can make the blending process of Pixel Math more unpredictable. For example, If you have a high intensity Oiii image with a low intensity Ha image, then blending them can cause the blue channel to over-saturate with just a difference of a percentage or less. It is much easier to produce reliable results in Pixel Math when the images being blended are of the same intensity levels. In order to achieve this, we need to perform two main operations, as closely to identical as possible, on both Ha and Oiii images. These include Background Extraction and Histogram Transformation. Let’s jump in!

The Duo-Narrowband Images

To begin with, we will need our stacked results of Ha and Oiii images. If you are not familiar with these, Ha is a Hydrogen Alpha channel of the spectrum that resides in the 656.46 nm band of light. Oiii channel falls primarily in the 500.7 nm band and secondarily in the 495.9 nm band. Here is an illustration of the duo-narrowband transmissions allowed to pass in my Optolong L-eNhance duo-narrowband filter. (Disclosure: Agena Astro Affiliate link – Please consider supporting me by using this link if you’d like to purchase this filter. It is at no additional cost to you, I make a small percentage from Agena.)

In my process, which is normally multiple night’s sessions, I will use Sirilic to process the lights, biases, flats, and darks from each night’s session in order to create the Ha and Oiii stacked result images. I will have another video and post dedicated to installing Python and Sirilic on Mac and processing multi-night images in the near future, it is a really powerful tool and I enjoy using it! I will often add my nightly data to an ongoing job that I have saved and do practice processing to see how the images are developing as I gather data. This is also a great way to practice processing techniques! Keep an eye out for the Sirilic post here and the video over on my AstroAF YouTube Channel! Once I have the Ha and Oiii stacked result images in my work directory from Sirilic, I will copy those over into a processing directory of my capture project and work on the copies, keeping the original stacked results un-modified as a backup.

Pre-Processing Ha and Oiii In Siril

Now that I have my stacked Ha and Oiii image results in my processing directory, I can begin getting the images ready for Pixel Math blending. Open Siril, at the time of this article I am using the Siril 1.2.0 release version. To begin, I start by setting the Home directory in Siril to my processing directory of my capture project.

At this point, I only have the two images within this directory. Clicking the Open button in Siril, I open the Ha image first as it, generally always, has the higher intensity as compared with Oiii image.

With the Ha image loaded into Siril, one would normally do an initial crop. However, we don’t wan’t to crop at this point because when working with the images in Pixel Math, they must be exactly the same dimensions. So we will leave cropping to a later stage of the processing steps following Pixel Math. Instead, we will jump right into Background extraction to remove any gradients from our image backgrounds and perform a smoothing operation to help avoid removing any nebulosity in the image.

Background Extraction In Siril

While this article attempts to provide adequate information for the goal of preparing images for Pixel Math, it does not a deep-dive into Background Extraction in Siril. I definitely recommend Deep Space Astro’s Video “An In-Depth Look At Background Extraction In Siril” for a more comprehensive explanation of the feature. For our purposes, navigate to the Image Processing drop-down menu in Siril and select Background Extraction, found near the bottom of the menu list. The Background Extraction dialog will open, allowing us to configure the parameters for our extraction process.

Here are my settings for this project, starting from the top:

  1. Interpolation Method – Radial Basis Function (RBF) is the recommended and most modern interpolation method available in Siril. This method synthesizes the sky background to remove gradients. This is the method that I use most often and the one that is used in this processing demo.
    • The other option available is the Polynomial Interpolation method. This is most appropriately used for simple background gradient removal, most appropriate for removing background gradient on subs when applied to sequences.
  2. Smoothing – the amount of Smoothing applied between grid samples. This process of the extraction helps protect nebulosity from being removed in the extraction. I generally just leave Smoothing set at the default of 0.50.
  3. Samples Per Line – The number of grid samples placed per row. When using RBF, it is not necessary to place a large number of samples. In this case I am placing 10 samples per row of the grid.
  4. Grid Tolerance – This is the tolerance of global sample rejection, by sigma value. Lowering this setting will make the process much more restrictive to the contents of the individual samples.
  5. Add Dither – Dither or Die!! Adds noise in order to randomize quantization error. This prevents large-scale patterns such as color banding.
  6. Generate – Generates the configured samples on the image, shown as red boxes.
  7. Clear – Clears the generated samples grid.
  8. Correction:
    • Subtraction – Mainly used to correct additive effects, such as gradients. This is the correction method used in this demo.
    • Division – Mainly used to correct multiplicative effects, such as vignetting
  9. Compute Background – Computes the synthetic background and applies the correction settings to the image.
  10. Show Original Image – Allows you to toggle between the background extracted version and the original to compare.
  11. Close – Closes the dialog
  12. Apply – Applies the background extraction to the image being processed. Note, until you hit apply you can generate and compute background iteratively. You can always undo following to return the image to prior state.

Set the parameters of the Background Extraction dialog to meet the needs of your image. Once set, click on the Generate button to generate the samples grid on top of your image. Here are my rules of thumb (tips) for grid samples.

  • Samples should never be placed on stacking artifacts. If the samples generation places them in such a location, be sure to right click on these samples in order to remove them.
  • Samples should never be placed on stars or nebulosity. Be sure to remove any samples placed on stars or nebulosity by right clicking on them to remove.
  • Find places to set samples that represent the background of your image, most notably, black space.
  • You do not need a million samples for RBF interpolation method. Seriously, just like 15-20 samples is plenty.
  • When removing samples by right click, you don’t have place your mouse directly on the sample. Siril will remove the closest sample in proximity to your mouse cursor. This helps speed up sample removal.

Once you have applied the Background Extraction we are ready to move on the to the next step of pre-processing.

Histogram Transformation

The next step for Processing Duo-Narrowband Images With Pixel Math In Siril is to apply a Histogram Transformation to the image. The goal of this step is to establish a uniform intensity level of the image using the Histogram Transformation tool along with the Statistics view. We will use the Statistics view to monitor and set the Median value to an amount appropriate for the image being processed. You can access the Statistics view by right clicking and selecting Statistics from the context menu. In my case this was around 10,000. Navigate to Image Processing tab and open the drop-down menu to select Histogram Transformation. As is normal, stretch the image to bring out the details, setting the black point, and avoid clipping the image data. Refer to the Statistics window median value and note the value established when you have stretched the image to your desired level. We will use this same value for stretching and matching levels of the Oiii image when we get there.

Once you have set your desired histogram levels we are done with the Ha image for the time being. It is easy to forget to save your image at this point. Either click on the Save button or Save As to create a new file. An appropriate filename for Save As might be something like appending “BHS_” to the filename, indicating that this version has had Background extraction, Histogram transformation, and level set in Statistics. That is just for example, do whatever makes sense to you.

Working With Oiii Image

Basically, the operations on the Oiii image will be exactly the same as that already performed on the Ha image. Run back through the process with Oiii, starting at the top of this article and reproduce the steps to get back down to this point. The only difference will be the exact Background Extraction points placed on the image. For the most part though, you can use the exact same settings to generate grid points and then manually edit as needed for the Oiii image. Set the intensity level with Histogram Transformation and Statistics view to the same median value you established in your Ha image. This will insure that the two images are matched in intensity prior to blending within Pixel Math. At this point we are ready to start processing duo-narrowband images with pixel math In Siril!

Processing Images With Pixel Math In Siril

Finally! This is where the fun begins! Pixel Math is powerful and it it like having a killer box of Crayons to work with your astrophotography images! To get started, navigate to the Image Processing tab to open the drop-down menu and find Pixel Math way down at the bottom of the list. Open the Pixel Math Dialog to get started.

Here is what the Pixel Math dialog looks like in Siril. Let’s do a quick run-through of the items in this dialog:

There are five main parts to this dialog. At the top there are 3 fields which are where Pixel Math expressions may be entered.

  1. Expression Fields
    • The RGB/K field is used for when the desired result is to be monochrome (Use single RGB/K expression is checked).
    • R (Red), G (Green), and B (Blue) fields (Use single RGB/K expression) is un-checked). These fields are used to create and RGB image by adding expressions which modify the related color channel.
    • The buttons to the right of the fields are used for saving your expressions to the Presets area.
  2. Images Area
    • Using the + and – buttons found at the top of the dialog, add or remove files to be processed to this area. These are the images to which Pixel Math will be applied.
    • Variable – User-defined variable name to give to the image
    • Path – The path to the image that has been loaded into Pixel Math
    • Functions – Mathematical functions which may be used in expressions. There are two types, those that may be applied to a pixel and those, such as statistics, which are applied to the entire image.
    • Operators – List of Mathematical operators that may be used within expressions.
  3. Parameters Field
    • Define a comma-delimited list of parameters which can be used in expressions. You can provide a value to a parameter that will be used to replace the parameter key used in the Pixel Math expressions.
  4. Output
    • Used for scaling an image to a desired range.
  5. Presets Area
    • List of saved expressions that may be quickly called back from the list and inserted into expression fields.

Applying Pixel Math Expressions

In my example, the first thing I do is to load the images into the images area, using the + button found at the top. of the dialog. Once both images have been loaded, I modify the variable name to “H” for the Ha image and “O” for the Oiii images. The reasoning for this is to keep the variable names as short as possible yet still know their meanings when looking at them. When we use these variables in Pixel Math, the variable will be referring to the associated file.

With variables assigned, they may now be used in Pixel Math expressions in the expression fields. First, I uncheck the “Use single RGB/K expression” checkbox since I intend to produce an RGB image. Now, the R, G, and B fields all become available. Here is a list of expressions that I have been playing around with. Feel free to grab them and see if they work for you!

Example Expressions

O*.65+H*.35
O*.8+H*.2
O*.85+H*.15
0.6*H+0.4*O

Looking at any one of these expressions we can see our variables O and H being used along with standard mathematical operations. For example, O*65+H*.35: This expression is calculating 65% Oiii + 35% Ha. You can place this expression in any of the R, B, and/or B fields in order to affect the color blending of that channel. Once assigned, simply click on Apply to view the result. You can iterate through different combinations as much as you want. Make a change and hit apply again to see a new result. In the most simple use of Pixel Math, you could just use the “H” and “O” variables in the R, G, and B fields in any combination you wish. For example to created an HOO image you would place H in the Red field and O in the Green and Blued fields:

I suggest playing around with combinations of expressions and color channels, along with basic H or O assignments to achieve different color results. Iterate through different expression assignments and just have fun seeing the effect the changes have on your image output! One final thing to have a look at is the Parameters field.

Using Parameters

Parameters allow you to assign key = value pairs witin the Parameters field. You can add multiple parameters, delimited by comma. For example, you could create the following parameters:

k=.65, l=.35

Now, within your expressions you can use these parameters rather than using the values directly in the expressions fields. What this looks like then is expressions using k and l:

O*.65+H*.35 would become O*k+H*l

This is super convenient because instead of editing the numbers within the expression fields, you may leave them unchanged and simply modify the value of the parameters and click Apply. One thing to note is that most often you will be using combinations of percentages sum should equal 100% (or 1). As seen in the above expressions, O*.65+H*.35, the sum of .65+.35 equals 100% (or 1). While this is a best practice, you can certainly use combinations of values that do not equal 100%. There is no reason not to experiment in this way if it help you get to an output result that you like. One final example that I would like to share is one which allows you to automatically set the values for both Ha and Oiii with a single parameter. This expression is the following:

k*H+~k*O

The real power in this expression is the tilde (~) which in this case represents a bitwise operator (1-) for inversion of the image mask. Thus rather than being perhaps .65 as shown above in k=.65, the value of K will be the inverse of the mask value of .35. In effect, we can use this to get the same result as O*.65+H*.35 but only using the parameter of k=.65. Here is an example of usage.

Wrap Up

Processing duo-narrowband images with pixel math In Siril doesn’t have to be daunting. It is possible. to keep things simple, experiment with different expressions and parameters to achieve different blending effects, and have a great deal of fun doing it! Make sure you go through necessary pre-processing steps to remove background gradients with Background Extraction, ensure that the images have the same (or very close) intensity levels using Histogram Transformation. You can achieve this by using the Statistics view, accessed from the context menu, right clicking on your image. Then, experiment with expressions and have fun seeing what kinds of results you can get with different permutations of expressions in the expression fields. As I’ve said, Pixel Math is like a really cool box of Crayolas for your astro images!

Cheers! I hope. you found this article on processing duo-narrowband images with pixel math In Siril useful! Please feel free to comment below with questions, additional ideas than what i’ve provided, describe how you use pixel math and share any expressions that you have found useful in your image processing!


Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.