Tutorial (PixInsight):
Enhancing Feature Contrast
Post-processing images tends to go through a standard regimen of processes to bring them from pre-processed images to final results that are published. This tends to involve noise reduction, colour-combination (if initially working with monochrome images), stretching to non-linear and even sharpening fine details. Either way, the end result can benefit from some extra treatment - in this case, to enhance the contrast in features, some of which may be hidden in bright nebulosity.
This tutorial goes through the process of enhancing the contrast in features of a non-linear image. A colour image is used as it demonstrates the techniques best, but it is stressed that a monochrome image can receive the same treatments described here. The colour image used as an example in this tutorial is post-processed cumulatively through the PixInsight processes and script applied as a kind of workflow. The three processes described are HDRMultiscaleTransform, LocalHistogramEqualization and CurvesTransformation. As an ending, the DarkStructureEnhance script is also described.
Assumed for this tutorial:
Please feel free to ask questions or leave comments via the comments section on the bottom of this page.
This tutorial goes through the process of enhancing the contrast in features of a non-linear image. A colour image is used as it demonstrates the techniques best, but it is stressed that a monochrome image can receive the same treatments described here. The colour image used as an example in this tutorial is post-processed cumulatively through the PixInsight processes and script applied as a kind of workflow. The three processes described are HDRMultiscaleTransform, LocalHistogramEqualization and CurvesTransformation. As an ending, the DarkStructureEnhance script is also described.
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 different types of masks (read this).
Please feel free to ask questions or leave comments via the comments section on the bottom of this page.
1. HDRMultiscaleTransform
HDRMultiscaleTransform is a process that can perform seemingly magical enhancements to the dynamic range in an image, recovering details that seem hidden behind overly bright areas. For example, the core of the M42 Orion Nebula or the spiral arms of a galaxy near its core. Though this process can be applied to monochrome and colour images alike, we will be working with a colour image as this demonstrates the enhancements more clearly. Moreover, HDRMultiscaleTransform should be applied to non-linear (stretched) images and as such, the image we are working with is a non-linear image as well. Since this process would be applied fairly late into a post-processing workflow, your image will no doubt be non-linear at that point and may have even been LRGB- or narrowband colour-combined at this point (if initially working with monochrome images). The working image used here is therefore a good example.
This tutorial will run through the application of all the processes and the script listed, one after the other in the order listed, rather than applying each one separately. We start with a fairly post-processed non-linear colour image. This is a bicolour narrowband image that has been noise reduced, stretched, colour-combined and finally noise reduced further.
This tutorial will run through the application of all the processes and the script listed, one after the other in the order listed, rather than applying each one separately. We start with a fairly post-processed non-linear colour image. This is a bicolour narrowband image that has been noise reduced, stretched, colour-combined and finally noise reduced further.
Though there is already a lot of detail within this image, it is clear that the very bright nebulosity can indeed hide some of the fine filamentary details underneath. For anyone familiar with the likes of MultiscaleLinearTransform, MultiscaleMedianTransform or ATrousWaveletTransform, note that HDRMultiscaleTransform works in much the same way - by targeting layers corresponding to pixel scales containing features (hence its name). This then brings us to the first setting, Number of layers. The default setting of 6 means that the first 6 layers are going to be targeted by the process (these layers correspond to pixel scales of 1, 2, 4, 8, 16 and 32 pixels). The Number of layers setting is critical to achieving a desirable result as changing it by only 1 can yield wildly different results. Alas, different images benefit differently from this. For an image such as the one I am working with here, I would expect large values of Number of layers to be beneficial as there are a lot of large structures present. For an image of a galaxy with very small, fine details on the spiral arms, smaller values of Number of layers may work best. Experimentation is key.
To start off, we will use the default value of 6 for Number of layers - this is a good value for most cases. Number of iterations relates to how many times to run the process successively. Since we want to test settings, we will keep this at the default of 1.
To start off, we will use the default value of 6 for Number of layers - this is a good value for most cases. Number of iterations relates to how many times to run the process successively. Since we want to test settings, we will keep this at the default of 1.
The option for Median transform makes HDRMultiscaleTransform use a different algorithm to perform its job. Hovering the mouse cursor over this option makes PixInsight report that indeed neither algorithm is better than the other, as they are different, though Median transform tends to avoid dark ringing around stars, but takes longer to process. Since we want to avoid dark ringing around stars without having to worry too much about using the Deringing settings (which can be used if you wish to tweak further!), we enable Median transform. As this is a colour image we are working with, it is recommended you enable the To lightness option, which will perform this dynamic range enhancement to the lightness of the image and preserve the colour. This option is not required if you are working with a monochrome image, of course. The next option that we should enable is Lightness mask, which forces HDRMultiscaleTransform to apply its algorithm most strongly to the brightest areas of the image. This is indeed what we want as it is the bright areas of an image that tend to benefit the most anyway.
The Midtones Balance option at the bottom should be kept at the recommended Automatic as this does a wonderful job of preserving the detail in the image and enhancing dynamic range as the process does its job. Before we apply the process to the image however, we should use a mask. A simple and good mask to use for HDRMultiscaleTransform is one produced with RangeSelection, to select out only the bright nebulosity in the image, and exclude some stars as well, with a large setting used to smooth out the mask image. Details of these mask generation procedures are the subject of another tutorial.
Above we see the range mask image on its own and its application to the image we are processing. All that remains now is to apply HDRMultiscaleTransform to the image, with the bright nebulosity areas unprotected. Below, the mask applied is still active but has been hidden for clarity.
The second screenshot above shows the altered image. Clearly much of the overall brightness of the bright nebulosity has been drowned out and a lot of the filamentary detail previously hidden has been pulled out. Though the final result looks good, we can experiment with different settings for Number of layers. For example, below we see the image when Number of layers is set to 4, 5, 7 and 8 (in that order).
Indeed HDRMultiscaleTransform takes a while to run on the entire image, particularly with Median transform enabled, even with the mask. Small preview boxes over areas of interest are a good idea to test out different settings quickly. Either way, the above shows that altering Number of layers has dramatic effects on the final result. It is purely your choice of what setting to use but it looks to me as if a setting of 8 gives the image a much nicer overall look in terms of dynamic range.
Once you are happy with the Number of layers setting, it is time to think about tweaking the Number of iterations setting. Usually the default of 1 works well but 2 can also produce excellent results without overdoing it (depends on the image!). The Overdrive setting can also be increased above 0 to provide more fine tuning. This setting essentially scales how harshly to enhance dynamic range per iteration. It is a good idea to first set a good Number of iterations and then think about Overdrive. So, we increase Number of iterations to 2 and apply the process with Number of layers set to 8.
Once you are happy with the Number of layers setting, it is time to think about tweaking the Number of iterations setting. Usually the default of 1 works well but 2 can also produce excellent results without overdoing it (depends on the image!). The Overdrive setting can also be increased above 0 to provide more fine tuning. This setting essentially scales how harshly to enhance dynamic range per iteration. It is a good idea to first set a good Number of iterations and then think about Overdrive. So, we increase Number of iterations to 2 and apply the process with Number of layers set to 8.
This is looking excellent at this point, with tons of filamentary detail popping out of the bright nebulosity. You may wish to make use of the Overdrive feature to be a little more aggressive within the same number of iterations, but it is up to you. Small values of Overdrive should do the trick, such as 0.100 to 0.200 for example. If despite your protective mask and use of Median transform, you are getting dark ringing around stars, you can enable Deringing and experiment with small values for Small-scale and Large-scale until the dark ringing is not an issue.
Indeed HDRMultiscaleTransform can be applied one more time over the image, but generally the second application is done to a much smaller Number of layers (usually 3 or so) and with Number of iterations set to only 1, generally with no Overdrive. Experimentation is key. You may not need a second application and indeed you may not like the results anyway. At this point, we are done with HDRMultiscaleTransform.
Indeed HDRMultiscaleTransform can be applied one more time over the image, but generally the second application is done to a much smaller Number of layers (usually 3 or so) and with Number of iterations set to only 1, generally with no Overdrive. Experimentation is key. You may not need a second application and indeed you may not like the results anyway. At this point, we are done with HDRMultiscaleTransform.
2. LocalHistogramEqualization
The next process to apply to our working example image is LocalHistogramEqualization. This will go a long way to recovering some of the brightness in the key features in the image. This process requires the image is non-linear and essentially strongly enhances contrast by its very nature. It works equally well with monochrome and colour images.
LocalHistogramEqualization is easily one of the easiest processes to apply to an image and also one of the most impressive in terms of the end results. A protective mask is recommended and for applying this process, I have simply used the exact same range mask image I was using with HDRMultiscaleTransform.
This mask essentially protects the background and most of the stars, leaving only the bright nebulosity unprotected, which is what we wish to enhance contrast in. The Kernel Radius setting of LocalHistogramEqualization defines how many pixels around the target to use to evaluate the contrast enhancement. Generally, the lower this value is, the stronger the overall effect but low values will tend to enhance contrast in small-scale noise and cause dark ringing around stars. The default value of 64 tends to work well but if you notice dark ringing around stars, raise it. A value I tend to use is 150.
You may wish to experiment with lower values of Kernel Radius to start with. Contrast Limit controls how strongly to enhance contrast in your image. The default setting of 2.0 will essentially double the contrast. I tend to find 2.0 too aggressive and usually stick to values between 1.2 and 1.4, though generally values between 1.1 and 2.0 work pretty well, depending on your image. Certainly something to experiment with as there is such a thing as over-processing and Contrast Limit is one of those settings that shows over-processing when you set it too high. I have set mine to 1.3.
The Amount setting has the exact same meaning as with all the other processes. This blends the original image with the enhanced image. For example, a setting of 0.8 in Amount will blend 20% of the original image with 80% of the enhanced image. This setting can be used to smooth things out in the final result - in a sense, fine tuning how aggressively you are enhancing contrast once you arrive at good settings for Kernal Radius and Contrast Limit. Histogram Resolution can generally be left at 8-bit (256) as this gives the best overall results with the vast majority of images. Circular Kernel is left enabled to enhance accuracy of contrast enhancement.
Once the settings have been set up, it is a simple case of applying the process to our image. Below, the mask is still active but has been hidden for clarity. The second screenshot shows the altered image.
As we can clearly see, much of the contrast in the bright nebulosity has been recovered by applying LocalHistogramEqualization, though the above is a little aggressive for my personal taste. A Contrast Limit setting of 1.2 yields nicer results in this case.
I could have also tweaked Amount to fine-tune the end result. Overall it is a matter of personal taste. The above is a sensible end result for my personal taste.
With LocalHistogramEqualization now applied, we move on to further enhancing this image with a simple adjustment made in CurvesTransformation. As before, our applications are cumulative as we continue with the end result shown above.
With LocalHistogramEqualization now applied, we move on to further enhancing this image with a simple adjustment made in CurvesTransformation. As before, our applications are cumulative as we continue with the end result shown above.
3. CurvesTransformation
The CurvesTransformation process is one that can adjust many aspects of an image. This process is best used towards the end of an image's post-processing, at which point the image will no doubt be non-linear.
CurvesTransformation has a number of modes in which it works. The default one, RGB/K, adjusts the image's histogram directly. Adjustments can be made to each colour channel individually, or to an image's lightness, colour saturation, etc. The default mode of RGB/K is the one we will use to adjust the contrast in the image. Keep in mind this is going to be applied image-wide and no mask whatsoever is active on the image.
It is strongly recommended you open the Real-Time Preview window on CurvesTransformation. Adjust the size of the window so you can clearly see what you are working with.
To make an adjustment to overall contrast, what we need to create here is an S-curve. If we click anywhere on the graph in CurvesTransformation, an anchor point is created, which we can drag anywhere we like and as we drag it around, it alters the shape of the curve. To enhance contrast, the darks need to be a little darker and the lights need to be a little lighter. Therefore, click a quarter up the straight line and drag the anchor point a little down. Then, click three quarters up the straight line and drag the anchor point a little up. This will produce the S-curve.
You may toggle the Real-Time Preview button on and off to quickly gauge at what the adjustment will do to the image. You may create a third anchor point in the middle of the curve, dragged a tiny little bit towards to the top-left corner of the graph, to increase contrast that little bit extra.
You may notice, depending on your image, that this process can be too much, too quickly. Simple, small adjustments made here are key to a good end result that does not look exaggerated or over-processed. Drag around the anchor points, while keeping the S-curve, until you are happy with the proposed end result shown in the Real-Time Preview window.
Once you are happy, before we apply the process, we can adjust lightness a little as well. For this, go to Lightness (or L) mode.
Once you are happy, before we apply the process, we can adjust lightness a little as well. For this, go to Lightness (or L) mode.
Note that this will only work on colour images as monochrome images cannot have their lightness adjusted - just their usual histogram via RGB/K mode as we have just done. To increase lightness a little, simply click the straight line in the middle and drag and anchor point a little towards the top-left corner of the graph.
This makes the overall image noticeably brighter. As before, less is more - do not overdo it. One final adjustment that can be made, if you are working with a colour image, is to colour saturation over the entire image. For this, we go to Saturation (or S) mode.
Again, all we need to do here is click along the middle of the straight line and drag the anchor point a little towards the top-left corner of the graph. A very tiny adjustment goes a long way and of course, the Real-Time Preview window is there to demonstrate the effect.
Once you are happy with all your adjustments, simply close the Real-Time Preview window and apply the CurvesTransformation process.
The end result has much higher overall contrast with fine details popping out more, in both brightness and colour. At this point, we come to a close on the use of CurvesTransformation and move on to the final cumulative step in our mission to enhance image feature contrast.
4. DarkStructureEnhance
DarkStructureEnhance can be considered a bit of a hidden PixInsight feature by some as this is not available as a process, but rather as a script. Those always working with processes may have missed it. You will find it under Utilities in the Scripts menu.
Generally speaking, the DarkStructureEnhance script can be used at the very end of a post-processing workflow and on the entire image, without any masks. It can provide those finishing touches that give the darker details in your image an extra boost to contrast over the brighter surrounding areas. All one needs to do to use this script is ensure the correct image is selected under Target image and click OK. Default settings work wonderfully well.
You may wish to tweak Amount, though the default of 0.40 is excellent as it blends 40% of the original image with 60% of the altered image and this avoids overdoing it. Iterations at 1 is good enough in most cases but you may wish to experiment with 2. Other than that, click OK, wait a bit and once you result pops up, undo and redo over the image to see the changes applied. If you are unhappy, undo, re-run the script and use different settings. Below, I have used default settings (shown above).
You may wish to tweak Amount, though the default of 0.40 is excellent as it blends 40% of the original image with 60% of the altered image and this avoids overdoing it. Iterations at 1 is good enough in most cases but you may wish to experiment with 2. Other than that, click OK, wait a bit and once you result pops up, undo and redo over the image to see the changes applied. If you are unhappy, undo, re-run the script and use different settings. Below, I have used default settings (shown above).
The end result certainly shows a much higher contrast to dark features in the image, which is the entire purpose of this script. Being too aggressive with it can lose some of the fine detail within these dark structures, so try to use conservatively and check the changes closely before continuing.
As a very final finishing touch to an image, you may wish to use CurvesTransformation once more to get that little bit extra out of it, but that is entirely optional and a matter of personal taste. Overall, these four processes have yielded much higher feature contrast over the entire image than was visible from the start of this tutorial.
As a very final finishing touch to an image, you may wish to use CurvesTransformation once more to get that little bit extra out of it, but that is entirely optional and a matter of personal taste. Overall, these four processes have yielded much higher feature contrast over the entire image than was visible from the start of this tutorial.
Comment Box is loading comments...