Image Stretching

Just as when a print emerges from a tray of developer, this is the magical moment when you find out if your patience has been rewarded

 

 

Following on from the chapter on noise and sharpening, stretching is the logical step into the non-linear workflow. This is the magical moment when faint details are made permanently visible and the fruits or your labor become apparent. The familiar automatic screen stretch that we use for assessing manipulations on linear images can be applied to an image but rarely gives optimum results. The golden rule is to not over-stretch. Although global stretching is frequently required to set a baseline, it is often the case that further manipulation requires selective application. Stretching alters contrast and depending on the tool, localizes the effect based on brightness or scale. As such, some enhancements overlap with sharpening effects to some degree. To distinguish between the two, I consider image stretching operates at a scale of 32 pixels or more.

Stretching an image not only brings about a miraculous change in the image, it also causes issues too, apparent noise in dark areas and loss of saturation being the most obvious. To keep both in check requires selective manipulation and at the same time, start with a quality image, in so much that it has sufficient overall exposure to have a high signal to noise ratio and not individually too long to cause clipped pixels in the first place.

As usual, there are a number of image stretching tools in PixInsight, optimized for specific situations. Their application is not automatic and tool choice and settings are heavily dependent upon the challenges set by the individual image. The most popular are;

LinearFit

HistogramTransformation

LocalHistogramEqualization

CurvesTransformation

MaskedStretch

AutoHistogram

LinearFit (LF)

This tool is unique in that it produces a linear stretch on an image by simply changing the black and white end points. This has been used before, during the first manipulations of the RGB channels, prior to combination into a color image. As such it is usually applied to the entire image.

The tool is automatic in operation and applies a linear equation to the image in the form:

y=m . x+c

Its purpose is to minimize the distribution of the image intensities between two images. Since only the endpoints are moved, the output is still linear and in the case of applying one channel of an RGB set to the other channels, it has the useful outcome of broadly matching the channels, producing an approximate color-balanced result and with a neutral background. It also has uses when scaling and matching narrowband channels, when the Hα signal is typically considerably stronger than the OIII and SII signals, as well as equalizing mosaic images before combining. There are a couple of instances where matching two images helps during advanced processing; for instance when matching the intensity of a narrowband color image and a RGB starfield, prior to combination. There are variations of the LinearFit tool, using scripts, that are specific to mosaic images, where an image is placed within a black canvas. These disregard the black canvas in the matching algorithm and are described in more detail in the chapter on mosaic processing.

fig129_1.jpg

fig.1 HistogramTransformation (HT) normally requires several passes to achieve the right level of stretch. Here, very mild shadow clipping is also being applied, along with a 20% dynamic range highlight expansion.

HistogramTransformation (HT)

This is the standard non-linear stretching tool. It can adjust both highlight and shadow endpoints, mimicking the actions of LinearFit and also adjust the midpoint too, creating the non-linear stretch element. It usefully has a real time preview function and displays the histograms of the target image, before and after stretching. There are also histogram zoom controls that facilitate careful placement of the three adjustments with respect to the image values. Each pixel value is independently calculated from the transfer function and its original value.

With this tool, it is possible to adjust the color channels independently in a RGB image and / or the luminance values. Since stretching an image pushes brighter areas close to peak values, this tool has a facility to extend the dynamic range using the highlight range control (fig.1). This allows any highlights to be brought into the safe region of say 0.8–0.9. The shadow range slider does the same for the other end of the scale. One wonders why that might be useful; so this is a good time to remember that sharpening and local contrast controls amplify pixel differences and an image sometimes requires a small range extension to ensure pixel values do not hit the limits later on. It does not hurt; a 32-bit image has enough tonal resolution to afford some waste and it is a simple task to trim it off any excess range later on. During the initial stretch it is more likely that the image will require deliberate trimming of the shadow region to remove offsets and light pollution (fig.1). Here, it is important to go carefully and not clip image pixels. Fortunately there are readouts next to the shadows slider that provide vital information on clipping, in terms of pixels and percentage. Ideally, if your image is cropped and properly calibrated, there should be no black pixels.

fig129_2.jpg

fig.2 LHE is very useful at enhancing contrast at large scales. At a high radius (above 150) it helps to increase the Histogram Resolution to 10- or 12-bit. Apply it in several passes, at different Kernel Radii and with the contrast limit set around 1.5 and a blending amount of ~0.7 (70%).

LocalHistogramEqualization (LHE)

This tool is fantastic at pulling out swathes of nebulosity from seemingly bland images without over-cooking the highlights in non-linear images. As the name implies, it attempts to equalize contrast over the image, so that areas with low contrast have their contrast increased. As such LHE implements a conditional modification of pixel values. The concept of localized histogram equalization is not new and is an established algorithm. In the PixInsight implementation, a few further controls improve the visual result. As the name implies, the Contrast Limit control limits the contrast enhancement. Typically values are in the range of 1.5–2.5, above which, image noise becomes noticeable. The Kernel radius control sets the evaluation area and has the practical effect that a larger radius enhances larger structures.

In practice, use this tool after the initial non-linear stretch or later on, if the general structures need a gentle boost. It helps to apply it in several passes; building up contrast in small, medium and larger structures. If the image has a featureless background or prominent stars, it is better to selectively apply LHE and protect these areas with a mask. If the effect is too aggressive, scale back the Amount setting to proportionally blend with the original image. This may appear remarkably similar to the multi-scale sharpening algorithms. In one sense, they are doing similar things, but the LHE tool is operating at much larger scales (typically 32–300). At the very largest scales, increase the Histogram resolution setting to 10- or 12-bit. If the application of LHE causes excessive brightness in highlight regions (over 0.9), back up and apply a simple linear HistogramTransformation highlight extension of say 10% (0.1) to effectively compress the image tonality before proceeding with LHE once more.

Masked Stretch (MS)

This is another tool which, when applied correctly, has a miraculous effect on a deep sky image and for many, is the go-to tool for the initial non-linear stretch. The tool effectively applies many weak, non-linear stretches to the image, but crucially masks the highlight areas of the image between each iteration, using the intermediate result of the last micro-stretch to form a mask. The practical upshot of all this is that the masking process prevents the image highlights from saturating. This also benefits star color too. Stars take on a fainter periphery, with a sharp central peak, rather than a circular, sharply defined circle and extended diffuse boundary. This appearance takes some getting used to. Logically though, it makes more sense to have a point source and a diffuse boundary. The images that this tool creates are more subtle in appearance that those using a standard histogram stretch. It is important to realize this is just one step on a path. Crucially the highlights are restrained and a bolder appearance is a single mild stretch away (fig.4).

fig129_3.jpg

fig.3 The MaskedStretch tool has few options. The clipping function has a very profound effect on the output (fig.4). Try values between 0 and the default, 0.0005

This tool has few controls but even so, they create some confusion, not helped by the sensitivity of some. As usual there is no magic one-size-fits-all setting but the settings in fig.3 are a good starting point for further experimentation. From the top, the target background sets the general background level in the final image. Values in the range of 0.85 to 1.25 are typical. The default value of 100 for the Iterations setting works well, though it is worth trying 500 and 1,000 too. The Clipping fraction causes dramatic changes to image proportion pixels that are clipped prior to the stretch. Many use the default value of 0.0005, though it is worthwhile to compare the results using values between this and 0.0. With zero, the result can look pasty, but nothing that cannot be fixed later on (fig.4). The Background reference selects a target image, normally a small image preview that represents the darkest sky area and the two limit settings below restrict the range of values used in the background calculation.

MaskedStretch and HistogramTransformation complement one another in many ways. Some of the best results occur when they work together, either in sequence or in parallel. In sequence, try applying MaskedStretch followed by a mild HistogramTransformation, or the other way around. In parallel, some prefer the appearance of stars with MS and the nebula/galaxies with HT (figs.45). Start by cloning the un-stretched image and stretch one with HistogramTransformation and note the median image value (using the Statistics tool). Open the MaskedStretch tool and set the Target background value to this median value. Apply Masked-Stretch to the other image. On can now combine the stars from the MaskedStretch image with the nebula of the HistogramTransformation image through a star mask. The possibilities are endless.

fig129_4.jpg

fig.4 A smorgasbord of stretching, comparing a standard HistogramTransformation (HT) stretch versus Masked Stretch (MS) at 0 and 0.0005 clipping levels. Finally in the bottom right, is a combination of a Masked Stretch followed by Local Histogram Equalization at a medium scale. The MS images show better separation in the highlights and yet retain the faint nebulosity at the same time.

fig129_5.jpg

fig.5 Up close, one can see the effect of HT (right) and MS (left) on star appearance on this luminance stack. The saturation is limited in the MS version to a few pixels and hence the star will be more colorful in the MS version, especially if the Morphological Transform tool is selectively applied to lower star intensity too.

CurvesTransformation (CT)

If anyone has used the curves tool in Photoshop, this tool will look immediately familiar. Look a little deeper and you soon realize it goes much further. Unlike its Photoshop cousin, this tool can also change saturation, hue and the channels in CIE color-space. This is not a tool for extreme manipulations but a fine-tune tool, typically used towards the end of the imaging workflow. In particular it is useful to apply a gentle S-curve to an image to lower the shadow values and contrast, especially useful if the background is a bit noisy, and increase the mid-band contrast. This is often a better option than simply changing the shadow endpoint in the HT tool and clipping dark pixels.

It is also useful to boost general color saturation. In this case, selecting the “S” transforms input and output color saturation. A gentle curve boosts areas of lower saturation and restrains the already colorful areas from clipping one of the color channels. To avoid adding chroma noise to shadow areas, selectively apply a saturation boost in conjunction with a range mask, or if it is only star color that needs enhancing, a star mask.

If one needs to selectively boost or suppress saturation based on color, for instance, boost red and reduce green, one might use a mask to select a prominent color and use the CT tool. Practically, however, the ColorSaturation tool is a better choice.

AutoHistogram (AH)

I am not a huge fan of automatic adjustments; each image is different and I prefer to use my eyes and judge each manipulation on its own merit. Having said that there are occasions when a quick fix is required and it can be quite effective. This tool works using an assumption that the sky background is dominant in the image and aims to non-linearly stretch the image to achieve a target median value. There are only a few controls; clipping levels, target median value and stretch method. The clipping levels are sometimes useful to constrain the stretch to the image dynamic range. The readout is expressed in percentage clipping. It is not advisable to clip the highlights though a little clipping on the shadow end can be useful. Since the tool is automatic, is requires that any image borders are cropped to avoid unexpected results.

While the target median value sets the degree of stretch, the three stretch methods (gamma, logarithmic and mid tone transfer function) alter the shape of the non-linear stretch function. An explanation of the various algorithms is not as useful as trying each and judging their effectiveness for oneself. It is easy to try each in turn and assess the results (fig.6).

fig129_6.jpg

fig.6 The AutoHistogram tool has three stretching algorithms: logarithmic, gamma and mid-tone transfer function. These produce very different results. The mid-tone transfer function has a very similar effect to the standard HT tool. Remember that these initial stretches are the first step on a long road. One is generally looking for boosting faint nebulosity and good definition of brighter areas. The overall brightness can always be increased later on.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset