Tutorial (PixInsight):
Reducing Star Sizes
Images of extended nebulosity can at times require very long exposures and if you are not using extremely narrowband filters (such as Astrodon's 3nm range), stars can get significantly bloated. Bloated stars can be a distraction from the diffuse nebulosity that seams through the background. Reducing star sizes effectively debloats stars by pinching them inwards with an appropriate mask.
This technique has been documented by Rogelio Bernal Andreo before. It is written as a tutorial here for completion purposes. Beyond star size reduction, we also go over a procedure for complete star removal, particularly suitable for narrowband images. Both procedures make use of star masks and the MorphologicalTransformation process.
Assumed for this tutorial:
Please feel free to ask questions or leave comments via the comments section on the bottom of this page.
This technique has been documented by Rogelio Bernal Andreo before. It is written as a tutorial here for completion purposes. Beyond star size reduction, we also go over a procedure for complete star removal, particularly suitable for narrowband images. Both procedures make use of star masks and the MorphologicalTransformation process.
Assumed for this tutorial:
- Knowledge of operating PixInsight, related to dealing with images, processes and working with masks (read this, sections 3, 4 and 6).
- Your images have already been pre-processed fully (read this).
- Knowledge of producing star contour masks (read this, section 3).
Please feel free to ask questions or leave comments via the comments section on the bottom of this page.
1. Preparing the Star Contours Mask with StarMask
We begin with the image within which we wish to reduce star sizes. This procedure is usually applied a number of steps into post-processing. I tend to apply this procedure after LRGBCombination has been used to combine my Luminance and colour RGB images. At this point, the images are non-linear. The example below is the Eastern Veil Nebula as a non-linear LRGB image.
This is good example simply due to the sheer number of stars present, and because it is an LRGB image and the stars are therefore somewhat bloated from the long exposures. To produce the star contours mask, we first need to neutralise the brightness across the image. This would allow the StarMask process to better pick up stars no matter their comparative brightness. For this purpose, we open the HDRMultiscaleTransform process.
Of course, we do not want to apply this process to our image itself, so we duplicate the image (right-click on it and click Duplicate).
As we want to neutralise the brightness across the image in order to produce a good star contours mask, we will be aggressive as to how we apply HDRMultiscaleTransform. Set Number of layers to 3. The rest of the settings can be left at default. With the duplicate image selected, click Apply on HDRMultiscaleTransform (or drag and drop the New Instance button on to it).
With the brightness across the image neutralised in our duplicate, we can now get a good star contours mask out of it. For this, we open the StarMask process.
We first need to determine where the noise cut-off is for our background. To do this, simply zoom in a fair amount until you see the smallest stars and your background (not faint nebulosity - actual background). Left-click anywhere on the background and keep the left mouse button pressed. The Readout Preview will give you values for R, G and B (unless your image is monochrome, in which case it will give you a single K value).
The R, G and B values all seem to hover around 0.22 for my image. Small stars in the image are significantly higher at just above 0.4 and up. If we keep StarMask's Noise threshold value at its default 0.10000, it will pick up small noise specks as stars, and we do not want that to happen. Since my smallest stars seem to hover just over 0.4, I will enter 0.4 in Noise threshold.
To include larger stars in the star contours mask, we will increase Scale to 6. This value includes the stars of the usual scale you would want to reduce in size (it may not include massive stars in images and would therefore need increasing further for them to be included). We will reduce Large-scale and Small-scale to 0 as this will prevent the star mask from artificially increasing the size of the stars picked up (we want the stars in the star mask to be their true size relative to the image).
We do not want to smooth out the star contours picked up as small ones would get smoothed to looking like the actual stars (rather than small star contours). To avoid this happening, we simply reduce Smoothness from the default value to a much lower value such as 5. We also enable Contours as that is the main purpose of the mask we want to produce. Additionally, in order to get the star contours that come up to be more visible, we perform a stretch on the star contours mask image by decreasing Midtones to about 0.10000.
The StarMask process is now applied to the duplicate image - the one whose brightness was neutralised earlier. Simply select this image and click the Apply button on StarMask (or drag and drop the New Instance button on StarMask on to the image). The new star contours mask image will come up.
You may now close the StarMask process. You may also close the duplicate image that was brightness-neutralised, as we will not need it again. Simply apply the star contours mask to the original image. You may wish to hide the mask after applying it as otherwise most of the original image will appear red and you will be unable to see the effects of star size reduction.
The second screenshot above shows the mask is still applied to the original image, but is hidden.
2. Reducing Star Sizes with MorphologicalTransformation
With the mask applied to our original image, we now proceed to actually reduce the star sizes. For this procedure, we use the process MorphologicalTransformation.
The best Operator to use for this purpose is Morphological Selection. This Operator performs a combination of erosion (decreases size) and dilation (increases size). One of these is performed more strongly than the other, but the fact that it does a combination of both smooths out the end result more than just eroding it alone.
The default value of Selection 0.50 does nothing as it erodes as much as it dilates. If we decrease the Selection value below 0.50, it will erode more than it dilates. Conversely, if we increase the Selection value above 0.50, it will dilate more than it erodes. Since we wish to erode more than dilate, we decrease Selection. I find a good value to use for this purpose is usually around 0.20. Amount takes the same meaning as in other processes. If we leave it at the default of 1.00, the end result will purely be the altered image (with the reduced star sizes). We can instead opt to decrease Amount slightly in order to get a blend between the original image and the reduced star sizes image (for a nicer-looking end result). I will therefore change Amount to 0.75. This corresponds to 75% the reduced star sizes image with 25% of the original image. Iterations should be increased slightly as well as a single application (Iterations 1) is insufficient for this purpose. Good Iterations values to use here are usually 3 or 4. I will opt for 4 in this case.
The only thing left to alter is the Structuring Element. This defines the way MorphologicalTransformation is applied to your image. Since we are dealing with stars, it is best to make the Structuring Element resemble a star in shape. A quick way to do this is to increase Size to 5 (25 elements).
You will notice the Structuring Element on the left is now 5-by-5 in size. To make a star shape, simply click all the black squares except the four corners. Clicking them turns them white, which enables them. If you make a mistake and wish to turn a white square black, simply click the square while holding down the CTRL key on your keyboard. When you are done, your Structuring Element should look as follows.
All that is left to do is apply MorphologicalTransformation to the original image (with the star contours mask on it). Simply click Apply on MorphologicalTransformation (or drag and drop its New Instance button on to the original image). Below there are two screenshots. The first one is before application, the second one is after application.
The difference is definitely noticeable, with more of the diffuse nebulosity becoming visible and the nebula as a whole standing out more. If you wish to be more aggressive about it, you could increase Iterations further, or decrease Selection further. I recommend leaving Amount at 0.75 as a maximum, in order to produce a more natural-looking end result.
Once you are happy, you may close the MorphologicalTransformation process and close the star contours mask without saving it. It is important to note that if you want to apply this procedure a second time (keeping the changes from the first application), you should re-create the star contours mask as described in section 1. This needs to be done because the stars present in the image are now smaller and so their contours are smaller as well, and the star contours mask should be representative of this.
Once you are happy, you may close the MorphologicalTransformation process and close the star contours mask without saving it. It is important to note that if you want to apply this procedure a second time (keeping the changes from the first application), you should re-create the star contours mask as described in section 1. This needs to be done because the stars present in the image are now smaller and so their contours are smaller as well, and the star contours mask should be representative of this.
3. Removing Stars Completely
Removal of stars is something that though can look a little odd at first, can also produce pretty stunning images. This procedure is always done on narrowband images and is never really done on LRGB images. In narrowband images, stars naturally appear less bloated and can be more easily removed while maintaining a natural look to the image. This is especially the case with narrowband images which have been captured with extremely narrowband filters, such as Astrodon's 3nm range. For example, the image below is a narrowband Bicolour Palette (Hydrogen-Alpha and Oxygen-III only) image captured with Astrodon 3nm filters. It is fairly late into post-processing and is already noise-reduced and non-linear.
The main requirement of star removal is a good star mask. It is generally difficult to extract all the stars from the image if some are above background and others are above bright nebulosity. What tends to happen is your star mask does not reproduce any stars that are above bright nebulosity. A nice technique to get the stars in an image is to delete the larger scale structure layers. Since we are working with a colour image here, we will first need to extract a Lightness image out of it. If you are working with a monochrome image, you can skip ahead a little.
Before extracting a Lightness image out of the colour image we have open, we must first open the RGBWorkingSpace process, set all Luminance Coefficients (Red, Green and Blue) to 1.000000 and click the Apply Global button.
Before extracting a Lightness image out of the colour image we have open, we must first open the RGBWorkingSpace process, set all Luminance Coefficients (Red, Green and Blue) to 1.000000 and click the Apply Global button.
What RGBWorkingSpace has done is define the Lightness of the image we are working on to be made up of an equal contribution from each colour channel. This way the Lightness image we extract is a true representation of what we are seeing. To extract a Lightness image, open the ChannelExtraction process, set it to CIE L*a*b* mode, disable a and b (only leave L enabled) and click Apply.
We can now close ChannelExtraction. To delete the nebulosity in this image while keeping the stars there, we need to use the MultiscaleLinearTransform process to delete large wavelet layers entirely.
Let us first try with the default 4 Layers listed. To disable the structures larger than Layer 4 (8 pixels), we simply double-click the layer labelled R (Residual). Once done, apply the process to the Lightness image.
Though the nebulosity appears to be completely gone and lots of stars remain, a lot of medium-sized stars (and the largest stars) have also disappeared. We may want to retain some of those medium-sized stars in this mask image, at least. Therefore we undo the changes made the image and select a larger value for Layers in MultiscaleLinearTransform. For example, I will try 6. This will show the first 6 layers and so disabling the R (Residual) layer now deletes structures larger than Layer 6 (32 pixels). Applying the process to the Lightness image again produces a better result, showing more stars.
Unfortunately together with including larger stars comes including larger structures overall, which includes some nebulosity. I can compromise a little by instead choosing 5 for Layers and then disabling the R (Residual) layer, which deletes structures larger than Layer 5 (16 pixels).
This is a nice compromise since it includes medium-sized stars but not much nebulosity. Since I am happy with this particular star mask so far, I close MultiscaleLinearTransform. The HistogramTransformation process can now help us eliminate the remaining nebulosity while accentuating the stars in the star mask image, so we open this process, select the Lightness image in it and activate the Real-Time Preview on it.
The aim is to stretch the image as one usually stretches images - by dragging the mid-tones slider toward the left. You will quickly notice that the nebulosity left over starts to gain contrast, which is not good.
To remove this remaining nebulosity, we simply black-clip by dragging the black-point slider to the right, clipping out these faint features completely. Avoid overdoing it as small stars will also disappear if you go too far, but avoid keeping any major nebulous features if possible.
Once happy, Apply the process to the Lightness image and close HistogramTransformation and its Real-Time Preview window. If we zoom in on our image, we see that indeed there is still some nebulosity left over.
This should now be tackled with CloneStamp to remove it completely. CloneStamp will literally copy an area of the image that you select, over the area you paint. We simply clone the black areas of the image over these nebulous bits to remove them completely, being careful not to remove stars or add new ones (by cloning them) accidentally. To use CloneStamp, simply set a Radius and then click on a black part of the image while holding down the CTRL key on your keyboard. Afterwards, simply paint over areas of nebulosity. You will need to continually adjust the area you are cloning by CTRL-clicking in black areas of the image to avoid cloning new stars into the image.
Once all the obvious nebulosity has been removed, click the Execute button on CloneStamp (green tick icon) to apply the changes. Since you are already using CloneStamp, this is a chance to remove any stars you do not want removed from your original image. After all, this star mask image we are creating will be used to target stars in the original image, for removal. To pick out specific stars, it helps to zoom out completely and overlay the star mask image over the original image. The transparency allows us to pick out stars we may want to leave unharmed.
Above, I have circled the stars I would like unharmed in the original image. The reason I chose these is because they are particularly bright and have a little bit of bloating to them. These can be extremely tedious to remove and are normally not removed completely as they are too large to smooth out into the surrounding nebulosity. Attempting to remove them tends to lead to odd discontinuities in the nebulosity that stand out. If you would really like to remove all the stars, then you can certainly go ahead, but it helps to avoid bloating them too much in exposures and in the post-processing workflow, so that this procedure is easier to carry out on them.
In any case, to avoid removing these stars, I go back to my star mask image and use CloneStamp to remove them as I did the visible nebulosity.
In any case, to avoid removing these stars, I go back to my star mask image and use CloneStamp to remove them as I did the visible nebulosity.
With the star mask image prepared, we now apply it as a mask to the original image. We also hide the mask in order to see what is happening as we remove the stars.
With the star mask in place, everything is protected except the stars we chose to target. We will first erode the stars in size a couple of times before we blend their remains with the surrounding nebulosity. To erode the stars, we will use MorphologicalTransformation.
As in an earlier section in this tutorial, we keep the Structuring Element resembling a star shape, with Size set to 5 (25 elements). The Operator we will use is Erosion (Minimum). We will leave the settings at default and apply the process three times to the original image (with the star mask image active). We could apply it only once with Iterations set to 3 but it is a good idea to apply it three times with Iterations set to 1 in order to be able to undo and redo through each application so you can watch the stars erode in size. After doing this, there appears to be an issue with the stars, which is visible when we zoom in on an area with lots of them.
What we are seeing is a result of a mismatch between the size of the stars in the original image and the size of the stars in the star mask image. Indeed the stars in the star mask image are a little smaller than in the original image, meaning that when they are eroded in size, their halo is left behind in the original image and it produces these discontinuities we are seeing. This reduction in star size is probably the result of HistogramTransformation's application, which black-clipped the fainter surrounding star halos, effectively shrinking the stars a little. To compensate for this, we can use MorphologicalTransformation on the star mask image.
First, we undo the changes made to the original image and then set Operator to Dilation (Maximum) in MorphologicalTransformation. To increase the stars in size a little, we simply apply default settings (with Iterations left at 1). This is applied to the star mask image, not the original image. Once done, we go back to the original image, re-select Erosion (Minimum) under Operator in MorphologicalTransformation and apply to the original image three times at default settings.
First, we undo the changes made to the original image and then set Operator to Dilation (Maximum) in MorphologicalTransformation. To increase the stars in size a little, we simply apply default settings (with Iterations left at 1). This is applied to the star mask image, not the original image. Once done, we go back to the original image, re-select Erosion (Minimum) under Operator in MorphologicalTransformation and apply to the original image three times at default settings.
That certainly looks like a better match, but there is still some discontinuity left behind, so clearly we must dilate the stars in the star mask image a little bit more. We therefore repeat the process outlined above but the dilation in this case only needs to be minor, so we set Amount to 0.50 to dilate the stars in the star mask image only a little. Once that is done, we erode the original image's stars three times again.
That looks like it is a lot more closely matched. The discontinuities left over are smoother and will be smoothed out later. We should keep applying the erosion until we can very barely see the stars anymore. This is why we keep Amount at 1.00. If we lowered it, there would still be some of the stars left over, just fainter. Just keep applying MorphologicalTransformation in Erosion (Minimum) mode again and again until the stars look more or less like the following.
It is now time to smooth out what is left over. You may close MorphologicalTransformation and open the MultiscaleMedianTransform process.
Since earlier on we produced the star mask image by disabling the R (Residual) layer after Layer 5, we will do the same here. We select 5 under Layers and then double-click to disable all first five layers, leaving only the R (Residual) layer active.
Now it is simply a case of applying the MultiscaleMedianTransform process to our original image several times over, with the star mask image still active. This process will blend the surrounding areas in order to smooth out the end result. Apply this process as many times as you feel necessary but applying it four to eight times is not as uncommon as one might think. You may only have to apply it three or four times - it depends on your particular image and how it looks. Below shows my result after applying it five times.
The above demonstrates how the vast majority of the stars (the ones I chose not to leave out) have been removed from the image. If you are happy with the results, you can close MultiscaleMedianTransform and the star mask image we created earlier.
Some final notes before closing. It is very clear that the star mask image is key to success here and the more closely this star mask image resembles the stars in your original image, the better the removal will be. If you are having problems excluding nebulosity while keeping small stars in the star mask image, you can actually use the StarMask process to make a star mask image out of it (following application of MultiscaleLinearTransform). HistogramTransformation and CloneStamp can then be used as they were above, except your job of excluding nebulosity while keeping small stars may be made easier by having used StarMask. It is also very clear that removing stars with significant bloating or coloured halos is difficult to do without leaving some blemishing in the final result. This is a fantastic-looking effect on narrowband images, but the extent of application to one's own images is completely up to the reader's discretion.
Some final notes before closing. It is very clear that the star mask image is key to success here and the more closely this star mask image resembles the stars in your original image, the better the removal will be. If you are having problems excluding nebulosity while keeping small stars in the star mask image, you can actually use the StarMask process to make a star mask image out of it (following application of MultiscaleLinearTransform). HistogramTransformation and CloneStamp can then be used as they were above, except your job of excluding nebulosity while keeping small stars may be made easier by having used StarMask. It is also very clear that removing stars with significant bloating or coloured halos is difficult to do without leaving some blemishing in the final result. This is a fantastic-looking effect on narrowband images, but the extent of application to one's own images is completely up to the reader's discretion.
Comment Box is loading comments...