Hi all,
As we already have
announced, the latest version 1.8.1 of PixInsight introduces the new MaskedStretch tool.
The original MaskedStretch technique was devised by Carlos Sonnenstein, and
a first JavaScript implementation was published by David Serrano as long back as September of 2007. Since then, MaskedStretch has been available as an official script in all PixInsight distributions. It has seen also several important improvements, especially
a faster implementation by Andrés del Pozo in 2010.
The idea behind MaskedStretch is conceptually simple: instead of stretching a linear image with a strong nonlinear transformation (or a set of similar transformations), such as the midtones transfer function (MTF) with the HistogramTransformation tool, apply a series of weaker MTFs iteratively, masking the image successively with the result of the previous iteration. As often happens in the algorithmic arena, this is one case of a pretty simple idea leading to something powerful and useful: MaskedStretch has proven one of the best ways to perform the initial stretch of linear deep-sky images. The iterative stretching/masking process prevents saturation of the highlights efficiently. At the beginning of the process the masks are very weak, so the stretching task really boosts the whole image. Once the image has reached good levels, the masks become stronger to protect bright structures selectively. The neat result is no saturated bright stars and nebular structures, which in turn means much better stellar profiles, less invasive stars—especially in wide field images—, and much better color saturation.
The new MaskedStretch tool is the result of a complete rethinking of the above idea. In the original script implementation there is a mask blurring feature that we have removed from our implementation. The reason is that such a blurring feature is a wrong concept in our opinion: MaskedStretch must be implemented strictly as a point operation; any low-pass filter applied to the masks turns the whole process into a neighborhood operator, with the consequent risk of artifact generation. Other than this, the tool implements a different algorithm to compute the MTF curves applied at each iteration. We have implemented also a user-selectable region of interest (ROI), similar to other ROI features in tools such as BackgroundNeutralization and ColorCalibration. Finally, the MaskedStretch process is fully parallelized, as is customary in PixInsight. MaskedStretch is part of the standard IntensityTransformations module, so it is open-source and its source code is available in the latest PixInsight Class Library (PCL) distribution.
Rather than a parameter-level description—which isn't very useful for relatively simple tools like this one in my opinion—, I'm going to show you how MS works through practical examples. In this post I'll work with an H-alpha image by
Antonio Pérez, who kindly allowed me to use it in an
example of StarAlignment's mosaic generation capabilities, back in 2010. The image is part of a six-frame mosaic of the Sadr region in Cygnus.
With images covered by extended nebulosity, the ROI feature of MaskedStretch allows us to define the mean value of a sky background area on the final image. The easiest way to do this is by defining a preview roughly covering a background region, as I am doing in the screenshot above. An alternative would be to not use a ROI and define an overall "background" value for the whole image—normally quite high; something in the range from 0.2 to 0.4 for example—, but in these cases working on a true background region is much more intuitive and controllable, in my opinion.
After selecting the preview as a region of interest, the screenshot below shows the result of applying the tool with a target background value of 0.08.
This target background value has been chosen to mimic the result of STF AutoStretch, which can be seen on the first screenshot. Now let's apply an equivalent—in terms of overall contrast and brightness—histogram transformation for comparison purposes.
and without more preambles, let's compare both results side by side on a region with some relatively bright stars.
The images speak loud and clear. These are the processed images and their histograms:
MaskedStretchHistogramTransformationIt's clear that the HT version has better contrast—although this is always a matter of taste, and hence discussable—, but the lacking contrast can usually be recovered after MS with a careful application of CurvesTransformation or, much better, by mixing both results selectively through masks and/or multiscale techniques. This
advanced example with NGC 7023 implements this technique.
For a more exhaustive comparison, I'll show the results achieved on two small crops covering bright stars. The three-dimensional representations have been generated with the 3DPlot script in PixInsight.
First crop - MaskedStretchFirst crop - HistogramTransformationSecond crop - MaskedStretchSecond crop - HistogramTransformationIn the next examples, I'll show you how MaskedStretch works for a completely different deep-sky target: a galaxy image where the field is mostly free sky background. I'll show you also the kind of results that can be achieved with color images.