CombineImages Script v0.6 - Redeveloped to improve functionality and support for JWST images

dcarr

Well-known member
Hello

I developed an early version of the CombineImages script in 2018 to allow users (ok, mainly me) to select a number of grayscale (master) images, assign whatever colours are desirable for each image, and then combine them to form a colour image. I have now redeveloped the script to improve its functionality, and to provide better support for the processing of images involving more than the usual number of filter sets – e.g. images from the James Webb Space Telescope (JWST) and Sloan Digital Sky Survey (SDSS.)

I understand this may be of interest to only a niche element of the astroimaging community, and although I have developed this script as a tool mainly for myself (and for educational purposes), others may find some use for it.

The script allows the assignment of almost any colour to each grayscale image. This may be useful for aesthetic reasons, but also if you desire more distinction between the chemical elements being imaged. Processing of RGB or HST images usually starts by assigning three master images (e.g. SII, Ha, OIII) to the three RGB channels – easy. But it's not so easy when you need to assign 4, 5, 6 or 7 masters (each with different colours) to the same three RGB channels.

What the script does is conceptually rather simple, but the implementation of the user interface has been quite complex. The complexity results from the need to support trial-and-error approaches by users seeking the best colours and methods of combination to provide aesthetically pleasing results.

To be clear, CombineImages is NOT an image stacking or processing tool. The script does not seek to replicate existing tools, and it is certain that other processing will be necessary. When the Script is finished combining your masters, it will be up to you to do the rest.

Further description and instructions are available through the Script.

I consider this v0.5 because it needs a little more user testing before I consider it ready to be v1.00.

So, a zipped ‘clean’ copy of CombineImages v0.5 script (i.e. without any test images) is attached and another with test input images is provided through my Google Drive. The test data incorporates JWST images of NGC3132, with 6 [filter] images already star-aligned and linear-fitted. The attached image (heavily reduced in size/quality) is the result of absolutely minimal processing of a combined image after using the script with specific settings (saved with the script). The minimal processing comprised one HistrogramTransformation, one CurvesTransformation and one SCNR (Green) only – no further processing.

Version 0.5 (With test images – i.e. large)

https://drive.google.com/file/d/114vxq8AE0Mqvc4p5q22S8Qt9iMIiUlUU/view?usp=sharing

Version 0.5 (‘Clean’ without test images)

https://drive.google.com/file/d/1GCUXzE_0KIC6LNi_cGC_bbUj0atcpZH-/view?usp=sharing

I would be particularly interested to know how the Script operates and displays on non-Windows systems and higher-resolution screens. It has only been tested on Windows systems.

See below for a recommended start-up approach using the test data.

Regards to all

Dean

-------------------

Recommended fast start-up approach:
  • Download and save the Script and data from my Google Drive transfer folder (links above).
  • Start PixInsight; select SCRIPT=>EXECUTE SCRIPT FILE, then select the script: ‘DC_CombineImages_v0.50.js
  • Accept the presented option of loading and selecting the test data already provided in the INPUT FILES folder.
  • Don’t touch any dialog sliders just yet!
  • Press the LOAD [SETTINGS] button at the top-right of the dialog, and select the only saved settings file present.
  • Press the COMBINE button, wait about a minute for the Script to run. Note: In other modes, execution is much faster (~6 seconds)
  • Review the results in the IMAGE REVIEW panel; use the MIDTONE ADJUST if necessary to see the results a little better.
  • Press SAVE to retain a copy of the combined image on the PixInsight desktop. The saved image will probably not look exactly the same as the Review Image you saw while running the script if you used a different method of stretching, any saturation boost or midtone adjustment at the time.
  • Process the image yourself – the Script has done all it's supposed to.
  • Read the USER GUIDE! It will explain a lot.

[ SEE UPDATED VERSION AT BOTTOM OF THREAD ]
 

Attachments

  • COMBINED_IMAGE_DUPLICATE reduced.jpg
    COMBINED_IMAGE_DUPLICATE reduced.jpg
    248.7 KB · Views: 179
Last edited:
Very cool. I tried it with the last image I had done, which had RGB and SHO, and experimented a bit with different percentages mixed in. It's very cool.

If you want a suggestion (or maybe it's a wish), I really like seeing different pallets side by side, or at least a way to flip between. Would it be practical to add tabs to the review images, and as you produce a new sample do a new tab, so one could go back to the prior ones (and as you do their settings replace the ones active)? Kind of like the EZ Deconv does. Because it's a script I don't see a good way to display them on the desktop and let one look at them before chosing the next possibility, but tabs might work?

Also, of curiosity, are you operating internally on the full resolution image? Is there any hope that one could do a smaller resolution and actually have live sliders, that update in (more or less) real time? That would be a HUGE win for people who are OCD about pallets and want to keep tweaking them. It may not be possible - too much data to crunch -- but it sure would be nice to have live sliders.

But all the whining aside, very nice, MUCH easier than doing the changes by hand in pixel math, and a hugely greater numbers of possibilities with a fairly methodical way to know what you are changing (something I do not excel at changing pixel math statements).
 
Thanks Darko
Good to know. Hope it continues to go well on your system.
Cheers
Dean
 
Last edited:
Thanks also Linwood, most appreciated
Yes, I will be looking at performance improvements, including along the lines of reduced resolution working images for preview.
Regards
Dean
 
Thanks also Linwood, most appreciated
Yes, I will be looking at performance improvements, including along the lines of reduced resolution working images for preview.

It's not to bad now as a change then hit preview, I used pretty large images and the wait was only mildly annoying. But the real prize goes to real time live preview sliders ([announcer talking really fast] actual prize may vary and may be imaginary).
 
Dean, I am having terrible issues trying to load your Combo app into Pi. See Image. Can You help? Maybe if you show me the https:// I can load it
 

Attachments

  • Screen Shot 2022-10-29 at 1.25.06 PM.png
    Screen Shot 2022-10-29 at 1.25.06 PM.png
    152.8 KB · Views: 133
Hi

My goodness !

There might be a ‘core’ icon missing or inaccessible on your system. The bitmap/picture named in the error message is one used to provide an empty box for users to click when selecting an image for linear-fit.

Two things to check:
  • Use the attached test version (v0.53 test) which removes references to that bitmap. You can also download the same version with test images from the following link: https://drive.google.com/file/d/1Rc0fpH7fIlJlqWONmEFeNxLV3LbGQO6V/view?usp=sharing Please remember this version is for test purposes only. Hopefully it should work on your system and help confirm the diagnosis.
  • Within PixInsight, please select SCRIPT=>Development=>CoreIconsBrowser and let me know if the icon is present on your system. Also, let me know if any other icons starting with ‘:/bullets/bullet …” and icons with the ‘.svg’ suffix are present.
Please let me know how it goes.

Regards

Dean

[ SEE UPDATED VERSION AT BOTTOM OF THREAD ]
 
Last edited:
Neither steps work. Here is screen shot
 

Attachments

  • Screen Shot 2022-10-29 at 6.30.12 PM.png
    Screen Shot 2022-10-29 at 6.30.12 PM.png
    234.8 KB · Views: 123
Hi

My goodness !

There might be a ‘core’ icon missing or inaccessible on your system. The bitmap/picture named in the error message is one used to provide an empty box for users to click when selecting an image for linear-fit.

Two things to check:
  • Use the attached test version (v0.53 test) which removes references to that bitmap. You can also download the same version with test images from the following link: https://drive.google.com/file/d/1Rc0fpH7fIlJlqWONmEFeNxLV3LbGQO6V/view?usp=sharing Please remember this version is for test purposes only. Hopefully it should work on your system and help confirm the diagnosis.
  • Within PixInsight, please select SCRIPT=>Development=>CoreIconsBrowser and let me know if the icon is present on your system. Also, let me know if any other icons starting with ‘:/bullets/bullet …” and icons with the ‘.svg’ suffix are present.
Please let me know how it goes.

Regards

Dean
Hello,
I was having the same issue and the first suggestion solved the issue for me.
 
Hello

Attached is v0.61 of the CombineImages script.

Again, I know this functionality will only be of interest to a niche element of the astro-imaging community – specifically, those people using PixInsight to combine multiple (> 3) grayscale images using user-defined colors to form new RGB images (e.g. JWST processing). Thanks to those who sent me private messages on the topic.

While I cannot do the impossible with sliders, I have added quite a bit of new software ‘machinery’ to greatly increase the speed of many operations (x3-4 times), but as you will see below, some of these changes come with limitations.

The most prominent changes are outlined below this e-mail.

Cheers

Dean

[ SEE UPDATED VERSION AT BOTTOM OF THREAD ]

---------------------------------------------------------------------------------------

The main changes are as follows:

A button (near the COMBINE BUTTON) allows users to create and use smaller working images in order to speed up the processing of images. Options include resampled images and cropped versions. The resampled images reflect entire images, but at lower resolutions. Cropped images reflect only portions of the main images (obviously).

• Both sets of options have strengths and weaknesses. Both scaling and auto-stretch operations may well lead to color and brightness differences from the main (full-size) image. These effects are most noticeable for cropped images because scaling during the combination process and auto-STF when using the Review Panel will use only a portion of the main image for calculating what settings to use.

• If you intend to use lower-resolution working images (either resampled or cropped) to speed the trial-and-error approach, you may wish to reuse stretch settings for the full-size image to reduce color and brightness variations. This is not a perfect approach but it may help. Otherwise, you may find that the 'RESAMPLED_0.50' mode may be a reasonable compromise between speed and color/brightness consistency.

• For cropped images only, you can double-click on a point within the Review Image to recenter the image. This is not intended to be a rapid pan facility, but simply a way to select specific areas for monitoring color/brightness levels.

A small window titled COLORIZED INPUT IMAGE [PREVIEW] at the bottom of the Review panel can be used to preview colorized versions of individual grayscale images. This may help you visualize the effects of adjusting settings for individual images. The image will update immediately upon many of the changes that you may make, except for slider movements. After any slider movements, you will need to reselect the image to refresh the view.

Status reporting has been upgraded to provide more feedback for long-running processes.

A red border will surround the Review Image if you have made any changes to settings and still require a Combine to generate the correct image. An orange border will briefly surround the image when a refresh is in progress.

The SAVE button now allows saving finalized/combined images on the filesystem as well as on the PixInsight desktop

[ SEE UPDATED VERSION AT BOTTOM OF THREAD ]
 
Last edited:
Hi @dcarr,

Thanks for this great script!
I managed to get NGC3324 looking very nice but I am having trouble with NGC3132 (your image above).
The output looks completely different using the JWST and even the JWST Gallery colours.

What processing steps did you do in order to get the amazing outcome you have above? (maybe you can share your image history?).

Any information on how you achieved it would be much appreciated.

See my example below.

COMBINED_IMAGE_JWST_GALLERY_SMALL.jpg
 
Thanks KMA

First the short answer, then some explanation.

1. The link to the Script on my GDRIVE folder provides access to test data. The test images are raw images, already star-aligned and linear fitted to the nircam_f444w-f470n_i2d_r image. If you press LOAD [SETTINGS] (top right of the dialog), you can load the settings that I applied to get the result provided in this post – these settings assume the use of the linear-fitted images.


2. I have provided several options that may or may not be useful or advisable in different circumstances – it is up to users to decide what they wish to do. In fact, I consider many of the settings I used to prepare the particular image in question may not be good practice in normal circumstances; nevertheless, testing and a trial-and-error approach led me to a reasonable result.

3. Here are some of the options I used that need caution to work with:

a. LRGBCOMBINATION. LRGBCOMBINATION is intended for use in non-linear colorspaces. So, using it to colorize linear grayscale images is unusual - to say the least. I provided this option because I do not know what types of images users will provide as inputs – I think they should be linear, but it is really up to the user.

b. Unlinked Scaling. I suggest you should start without using any unlinked/independent channel scaling in the combining process, nor ‘unlinked’ STF with the Review Image facility. This is not a rule; they can indeed be useful, but you need to be aware of the ramifications. Unlinked scaling/STF is very useful for ‘normal’ three-color palettes; e.g. Hubble SHO palette, where the Sulphur (Red) and OIII (Blue) channels may need to be equalized with the Ha (Green) channels to avoid very green images. There are many examples where this type of thing is a good thing in astroimaging (e.g. linear fits, unlinked stretches ….). However, when combining 6 images and placing the data into three channels, unlinked scaling/STF can somewhat ‘undo’ all your careful work adjusting color hues with sliders.

c. Linear Fit. The Script provides linear fit options in two places. The first is a preprocess; but you should be aware that after grayscale images have been ‘colorized, they are no longer fitted with the other colorized images. I have also provided the option to linear fit these mid-process colorized images before the combination process. This may seem logical, but it can lead to undesirable results. Note, linear fits can fail under normal circumstances where there is insufficient data in any of the image channels. In the case of this Script, this can happen if an RGB colorized image includes a channel with a ‘zero’ value (e.g. 255, 128, 0) - but the Script should continue silently without continuing to attempt linear fits when this happens.

d. ‘Max’ Combine Method. Be careful when using the ‘Max’ Combine Method; you can adjust color sliders all day without any changes flowing through to the final image if the input image with the maximum color channel value is not being changed.

4. As a final note, any saved copies of the combined images will not reflect auto-stretch/STF, mid-tone adjustments, or saturation adjustments used in the Review Image panel - they are for preview purposes only.

5. Sorry about the long discussion, but I just wanted to note that the settings used to gain the resultant image you see in this post are not necessarily good choices for other images.

Regards

Dean
 
Last edited:
Hi Dean, Thanks for the detailed response! I appreciate it.

I loaded up your images and settings but it turned all the stars green!


Screenshot 2023-01-03 at 11.40.jpg
 
Hi KMA

This is ‘normal’ 😊 with narrowband image processing. Combining images with colors assigned to better depict nebulosity etc often results in strangely colored stars. Stars can easily end up looking green, magenta, or any other color of the rainbow. There are a few options to address this issue:

1. Accept the star colors, which can be ok or completely unacceptable, depending on your tolerance for green/magenta stars.

2. Replace the stars with RGB images taken separately – probably not a solution in this case.

3. Process the image in a way that minimizes the unsightly star colors.

In the case of this image, I simply used the SCNR process, with ‘Protection Method’ set to ‘Maximum Neutral’. I have attached a process icon to help. You can also use a mask if you wish, but I did not find it necessary in this case for demo purposes only.

Regards

Dean
 

Attachments

  • SCNR.zip
    569 bytes · Views: 120
Last edited:
  • Like
Reactions: KMA
I would like to thank U so much for this script and all suggestions written up!!! Best best greetings from Italy!!! Wishing U all clear skies!!!
 
Finding this script very useful as well! Thank you. I use a 4k display on MacOS, with 2x scaling so it's effectively a high-dpi 1080p interface. I use PixInsight with "auto display scaling" and a font resolution of 125 dpi. It takes up the whole screen in this mode, but it's readable and useable.
Screenshot 2023-06-09 at 10.29.29 AM.png
 
The Combine Images script seems like a good idea, so I tried it out on my Mac and got the expected results.

Then I tried comparing the result of the Combine Images script pre-settings for NGC 3132 with a PixelMath treatment using an approach described in this forum, post #87 in the topic “Combining more than four filters in PI”. In the procedure I used, one converts a grayscale image to RGB and gives each channel a fraction of R, G, and/or B using Pixelmath. Each of the filters then has a unique color and the final image is created by combining the filters by adding them together in the most useful proportions. When I applied the PI menu choice Image —> Color Spaces —> Convert to RGB Color to the filters downloaded from post #14 in this topic, three of the filters came up red, including f212n, f356w, and f405n_f444w. The other three —f090w, f187n (pa-alpha), f444w_f470n — remained gray. Why is it that three of the six have somehow been preassigned to red? To convert one of the red filters to RGB format without the red, it was necessary to (1) convert the filter to RGB, (2) extract the channels from the RGB conversion, and (3) convert one extracted channel back to RGB using Image —> Color Spaces —> Convert to Grayscale. For some reason this had to be done before applying the ScreenTransferFunction. How might the unexpected red affect the results obtained by using Combine Images? What if one does not want any red in one of the affected filters?

Looking at the filter wavelengths brought up another issue for those working with multiple filters from JWST or other large scopes. I have in my notes from <https://en.wikipedia.org/wiki/NIRCam> that f444w is a blocking filter for f405 (Br-alpha) and for F470N (H). I take it then that f405n_f444w adds in the f405n to the wide band of f444w and that f444w_f470n adds in the f470n, so that we should treat both filters as wide band NIR, as there is probably no way to separate out f405n and f470n as bands of interest. Only one of the filters, f187n signals the emission band of a particular element, in this case Hydrogen, so one might give this band a color that would highlight the distribution of H, assuming that it does not have the same distribution of light as captured by a neighboring wide band filter. I’m not suggesting that Dean should have considered these points, but others using Combine Images may wish to regarding this target or others.
 
Last edited:
Back
Top