Update, December 2022: Note that GHS is now available as a fully integrated PixInsight process, providing improved speed and seamless integration with the PixInsight platform. This tutorial covers processing M51 with the GeneralizedHyperbolicStretch process that you can now find in PixInsight. |
In September 2021, Dave Payne posted a series of equations on AstroBin, saying the following at the time:
“I consider image stretching my make or break process in creating an image – unfortunately it is generally hit-or-miss for me. In an effort to potentially improve upon and parameterize image stretching, I have put together a Pixelmath sequence to stretch images in a natural, but controllable manner, that in my initial testing, is showing to improve upon the multiple uses of curves or histogram stretch and is easier to duplicate than “hand-drawn” curves, or my previously favourite method – Arcsinh stretch + Curves. “
The PixelMath expressions that Payne shared can be a bit complicated, so it’s important to understand how they work before applying them to your own images.
The good news is that Payne teamed up with Mike Cranfield to create the GHS script, which is mentioned in the title of this article. This script makes it much easier to define, evaluate, and apply various stretches, including the Generalized Hyperbolic Stretch.
To really illustrate the impact of using this script, I’ve prepared two images of Messier 51 – also known as the Whirlpool Galaxy. These images clearly show the dramatic difference between using an STF-based approach and the results of applying the Generalized Hyperbolic Stretch script. Sometimes, a picture really is worth a thousand words!
You can download the FITS files I used for this article here or from the Samples page. The files in the ZIP file are already aligned but are not stretched and there’s one file for each of the luminance, red, blue, and green filters.
I created the following image using the STF to stretch the luminance image and then applied the stretch to the image using HistogramTransformation. I then combined the R, G, and B images using ChannelCombination. The color image has a blue cast, so I used the BackgroundNeutralization and ColorCalibration processes at their default settings. I then applied an STF stretch to the color image and transferred the settings to the HistogramTransformation process to make the change permanent. I then used LRGBCombination to combine the luminance with the color image, and the following image is the result:
The brightness of the image is too high, which has the effect of washing out the details and color information. As a result, the galaxy in the image appears mostly white, and it’s difficult to make out any distinct features or structure. The stars within the galaxy are also hard to see, as the bright white light of the galaxy tends to overpower their fainter glow. Overall, the image appears very poorly defined and lacks the rich, vibrant colors and details that are typically associated with images of galaxies.
I created the following image by stretching the luminance and color images (I also used BN and CC) using the GHS script and combined them using LRGBCombination:
The difference between the two images is dramatic: the galaxy has many more visible features and structures. The galaxy appears as a beautiful, swirling mass of stars and gas with distinct spiral arms and bright, glowing cores. The stars within the galaxy are visible in various colors and intensities. The image is rich in detail and vibrant in color, providing a stunning and immersive view of the galaxy. In addition, the nebulosity around the upper part of the galaxy (NGC 5195) is apparent, the stars are not saturated, and the background is darker. I created this image in just a few steps using the GHS script and other PixInsight processes.
Before I get into how to use the GHS script, I explain how to acquire and install the script so that you can try it as well.
Installing the GHS Script and Process in PixInsight
Use the following steps to install the GHS script and GeneralizedHyperbolicStretch process:
- Start PixInsight
- From the menu, select Resources, Updates, Manage Repositories
- Click the Add button
- Enter the following URL: https://www.ghsastro.co.uk/updates/
- Click Ok
- Click Ok to close the Manage Update Repositories window
- From the menu, select Resources, Updates, Check for Updates
- Allow PixInsight to download the update
- Exit and restart PixInsight
The script appears under Script – Utilities – GeneralizedHyperbolicStretch ann the process under Process – IntensityTransformations – GeneralizedHyperbolicStretch.
Learn More About Astro Image Processing Using PixInsight
I have a page dedicated to a PixInsight broadband/LRGB and narrowband workflow, and my blog has a whole section dedicated to processing images using PixInsight. Also, consider downloading my free eBook about remote imaging using Slooh.com, a great way to boost the number of nights you can spend observing…Remote Astrophotography Using Slooh.com!
Using the GHS Script
I use the sample observation of Messier 51 in this section, so you can follow along if you like.
Start by opening all four files for the M51 observation using PixInsight.
Create the combined RGB image using the ChannelCombination process, and then close the R, G, and B images since we don’t need them anymore. Next, use the BackgroundNeutralization and ColorCalibration processes with their default settings to resolve the color image’s blue color cast.
You don’t need to do anything to the luminance image because it’s already aligned with the color image.
Start the GHS script (select Scripts – Utilities – GeneralizedHyperbolicStretch) – a large window opens on your PixInsight desktop.
The window has four primary sections:
- At the top is the Histogram display where you’ll apply and evaluate your settings
- Below the Histogram is the parameters section, where you make adjustments
- To the right is the Preview window that shows you what your image looks like after applying the parameters you selected
- At the bottom of the window are the Apply (green checkmark) button, close button (red X), undo/redo buttons, log window, preferences, documentation, GHS website link, and the reset button
The first thing you need to do is select the Target View, so you can set the image you’ll be working on. Select the M51_lum image. If you had applied the STF to the image, the script asks if you wish to remove the STF; answer Yes that you wish to remove the STF.
The preview image is very dark, which is expected because the histogram function is at its default, which maps pixels one to one.
We’ll first have to select the Symmetry Point (SP) value – this tells the script where to apply the stretch function.
Do the following:
- Use the Zoom slider to zoom into the histogram until you can see the spike in the histogram at about the halfway point in the histogram (for me, the value is about 17). Your screen should look something like this:
- Place your mouse pointer at the beginning of the rise of the histogram and click to place a blue marker line. Your screen should look something like this:
The green arrow points to approximately where to place the blue line, and the highlighted X value provides you with an idea of exactly where I placed the line. If you make a mistake, just click elsewhere to move the blue line. The blue line is a readout value that sets the X and Y values below the histogram. - Note the value of X, highlighted in yellow on the preceding screenshot
- Enter the value of X in the box labeled Symmetry Point (SP), shown in yellow in the following screenshot. Alternatively, to copy the value from your selected point on the graph, click the Send value to SP button.
The Symmetry Point is the point where the stretch will occour. By placing the symmetry point near the beginning of the histogram, we are focusing our efforts on the most significant part of the image. - Reset the Zoom back to the default of 1 by clicking the left-pointing arrow next to the Zoom bar below the histogram
- Set the value of Local stretch intensity (b) to 8
The local stretch intensity defines how much stretch will be applied to the selected region. Higher values are more intense, and lower values are gentler. - Drag the Stretch factor (ln(D+1)) to about 3.3 so that the spike in the histogram appears just beyond the 25% mark and the preview shows M51. This is what my screen looks like:
- Click the green checkmark at the bottom of the window to commit the stretch to your image.
- The preview image turns white because the script applies your selected stretch a second time. You can resolve this by clicking the Reset button at the bottom of the window.
- Close the script window
- The script asks if you wish to save your log before closing.
The log is a text file that saves the settings you used while running the script. You could use this information later to repeat your steps, but answer No to the question for now. - Next, create the color image by using ChannelCombination to combine the R, G, and B images. You may have already done this earlier so you can skip this step if you already have the combined RGB image.
The resulting image has a blue cast to it, which you can resolve by using the BackgroundNeutralization and ColorCalibration processes at their default settings. You’ll note that the background is uneven. You can improve that using AutomaticBackgroundExtractor at its default values, except for the correction method, which you set to Subtract; you can put checkmarks next to Discard background model and Replace target image. - Note the name of the RGB image
- Start the GHS script, select the color image from step 13, and remove the STF if you had applied it
- Repeat steps 1-5 for the color image
- The Symmetry Point (SP) is 0.00758, the Stretch factor for the color image is about 3.8, and the Local stretch intensity (b) is 1.0
- Click the green checkmark at the bottom of the window to commit the change
- Reset the script so that the preview window is no longer white
- Next, I’d like to improve the contrast around NGC 5195 (the upper galaxy of M51) to bring out the nebulosity a little more in the color image.
To improve the contrast, we need to find the approximate value of the pixels in the region. We do that by clicking the region in the preview window, which places a readout square where you clicked. The readout square is a little too large, so adjust its size to about 20 using the slider next to the Readout size or enter the value in the box.
In the big white box is the mean value of the pixel you selected. In my case, it is 0.30374 as shown in the following screenshot:
The pixel I have selected has a value of 0. 30374 (from the nebulosity in NGC 5195) – your number may differ, depending on where you clicked. - Click the Send value to SP button next to the number from the preceding step
- Enter or select 1.0 in the Local stretch intensity (b) box
- Slide the Stretch factor box to the right until you get to a value of about 1.7
The stretch is affecting pixel values around the 0.30374 value you found earlier and is adding contrast to just those pixels. - Click the green checkmark to commit the change to the image and then click the Reset button at the bottom of the script window
- Next, we’ll improve the saturation of the color image to bring out more color.
Below the Histogram window, click the radio button next to Sat for saturation. Set the Stretch factor to 1.0 and note the increase in saturation. - Click the green checkmark to commit the change to the image and close the script window (answer No to Do you want to save your log before leaving)
- Use the LRGBCombination process to blend in the M51_Lum image
- The background is a little light, so we can use the HistogramTransformation process to clip the shadows. Do the following:
Open HistogramTransformation and select the combined image in the dropdown. Open the real-time preview and click the button shown in the following screenshot:
If your image is a little dark, reset the HT process and drag the dark point arrow (the one on the left), to the beginning of the hump on the histogram graph as shown: - Close the real-time preview and apply the HistogramTransformation process to the color image
- Optionally, use the AutoIntegrate.js script to reduce noise in the image (under Extra Processing, select Noise reduction, set it to at least 5, and apply after selecting the combined image)
This is your final image – the galaxy has many visible features and structures and appears as a beautiful, swirling mass of stars and gas with distinct spiral arms and bright, glowing cores. The stars within the galaxy are visible in various colors and intensities. The image is rich in detail and vibrant in color, providing a stunning and immersive view of the galaxy. The surrounding nebulosity around NGC 5195 has more contrast with distinct differences in brightness and color throughout.
Where To Get More Information
The author of the GHS script, Mike Cranfield, has created a website featuring tutorial videos by Dave Payne and other experts demonstrating the various applications and capabilities of the GHS script. These helpful resources can be accessed here: ghsastro.co.uk.
Conclusion
The GHS script is a valuable tool for enhancing and extracting useful information from your astrophotography. This article has provided an overview of the GHS script, as well as guidance on how to install and use it. You’ve also had the opportunity to see the GHS script in action, using a sample image of Messier 51 and NGC 5195 as an example.
Update, December 2022: Note that GHS is now available as a fully integrated PixInsight process, providing improved speed and seamless integration with the PixInsight platform. This tutorial covers processing M51 with the GeneralizedHyperbolicStretch process that you can now find in PixInsight. |
You must be logged in to post a comment.