Author Topic: HaRGBCombination Script  (Read 99248 times)

Offline troypiggo

  • PixInsight Addict
  • ***
  • Posts: 258
Re: HaRGBCombination Script
« Reply #90 on: 2013 May 23 11:25:19 »
Not sure about RC5 but I just used in on RC7 and Harry's one just a few posts up worked fine.

Offline Ioannis Ioannou

  • PixInsight Addict
  • ***
  • Posts: 202
Re: HaRGBCombination Script
« Reply #91 on: 2013 May 23 11:33:52 »
Yap, I also installed RC7 and can confirm Harry's (Juan's) correction.

BTW, I though that Juan was supposed to release it with 1.8 ? (and hopefully clean it up a bit with his huge knowledge on the library? I did my best, but still there are some rough points to be fixed)
Clear Skies
John (Ioannis)

FSQ106N+Robofocus+QHY-22+SX USB wheel+Baader filters
SX OAG+DSI Pro guiding a NEQ6
PI for the rest :)

Offline gspiegelman

  • Newcomer
  • Posts: 5
Re: HaRGBCombination Script
« Reply #92 on: 2013 June 09 11:00:25 »
I have tried this script under 1.8, but I do not get the dialog to show, the script just appears to run and I get an error "Not enough layers". Can anyone help here?

Offline Ioannis Ioannou

  • PixInsight Addict
  • ***
  • Posts: 202
Re: HaRGBCombination Script
« Reply #93 on: 2013 June 10 02:36:52 »
gspiegelman,  you have to be more specific, what window you had opened when tried, what options you put in the script etc etc. It works fine with my 1.8rc7 (The latest, with Harrys' correction)
Clear Skies
John (Ioannis)

FSQ106N+Robofocus+QHY-22+SX USB wheel+Baader filters
SX OAG+DSI Pro guiding a NEQ6
PI for the rest :)

Offline Ioannis Ioannou

  • PixInsight Addict
  • ***
  • Posts: 202
Re: HaRGBCombination Script
« Reply #94 on: 2013 August 14 23:27:52 »
Hello PI forum,

Long time we did not improved this script (which BTW, still is not officially included in 1.8 ). Yesterday night I was watching the excellent tutorials from Gerald, http://www.werbeagentur.org/oldwexi/PixInsight/PixInsight.html , especially the Oiii Ha R G B linear combination. I was not surprised with the trick used, i.e. swap the colors to use the HaRGB script for Oiii combination (I have tried it myself in the past), but I realized that I'm guilty of negligence : swapping back and forth the colors to achieve the combination is a lot of wasting time for everybody, while the HaRGBCombination script can be expanded to be able to do the same with THREE Narrowband filters.

Today is a national holiday here, I woke up early, family was still sleeping, and so I decided to test again my limited knowledge in PI scripting and try to make our lives easier. The interface has been finished and you can find a preview below. As you can see it is heavily based on HaRGBCombination but it will be a new NBRGBCombination script ;) . BUT I have some questions on the maths and I would appreciate anyone that can assist . Originally Silvercap implemented the "Vicent method" with these PixelMaths (free form):

Ha <- (Ha*RGB_bandwidth-RGB*Ha_bandwidth )/(RGB_bandwidth-Ha_bandwidth) -  hmm , take out the stars ?   

R <- R+(Ha-med(Ha))*HaMultiplier - not sure but, take out the nebula ? Leave only stars ?  Continuum ?

Ha <- LinearFit(Ha with R)

R <- max(Ha,R)

and finally
RGB combination

Now then, I'm not familiar with this procedure, although I have used it a lot of times via the script. Digging into my saved PixelMaths from 1-2 years ago, I found differences on what I had understood as the "Vicent" method (although I understand the concept used), so I need opinions if the same can be used with other filters on other channels (with the corresponding Bandwidth of course, not all filters are 7nm like Baader's Ha).
 
In the case of Ha there is a hidden assumption: Ha is already included in R. But e.g. with O3, part of it is in Blue and part of it is in Green. How we handle this ? Different mixing multipliers ? And I do not feel confident on the first two maths and the result they produce - at least not without previewing the result before applying it. Maybe now it is a good time to review, revise and make them more robust and general ?

Opinions please!!!!
Clear Skies
John (Ioannis)

FSQ106N+Robofocus+QHY-22+SX USB wheel+Baader filters
SX OAG+DSI Pro guiding a NEQ6
PI for the rest :)

Offline troypiggo

  • PixInsight Addict
  • ***
  • Posts: 258
Re: HaRGBCombination Script
« Reply #95 on: 2013 August 15 02:31:54 »
That's exciting development.  Haven't played with it, but I'm curious what channels the 2 other NB images get mapped to?  With HaRGB script it's a given that the Ha goes to R.  Perhaps another option where you could map the NB images to the channel of your choice?

Offline Ioannis Ioannou

  • PixInsight Addict
  • ***
  • Posts: 202
Re: HaRGBCombination Script
« Reply #96 on: 2013 August 15 03:51:59 »
Of course, that's the idea. I may have to make the labels more clear,NBr means first narrowband that will be joined to R, NBg means second narrowband that will be joint to G etc. That way you can have 4 or 5 or 6 filters.



Using the same for HST or similar ? Hmmmmmm this is more tricky than it sounds, due to the way the combination happens now with pixelmath. Lets keep that thought for later. My target now is to expand the existing script.
Clear Skies
John (Ioannis)

FSQ106N+Robofocus+QHY-22+SX USB wheel+Baader filters
SX OAG+DSI Pro guiding a NEQ6
PI for the rest :)

Offline oldwexi

  • PixInsight Guru
  • ****
  • Posts: 627
    • Astronomy Pages G.W.
Re: HaRGBCombination Script
« Reply #97 on: 2013 August 15 10:29:52 »
Hi Ioannis!
Thats a great extension of the HaRGBCombination script.

As this script works perfect for me with linear data
i appreciate the shortcut you built in to mix every NB Image in any RGB Channel in any amount wanted!!!
Great.

Concerning Vicents method sometimes we use line 2, 3 or 4 but only when doing it manually.
For Line 1 of Vicents method we are just in progress todo research to understand it better...

Gerald

Offline Ioannis Ioannou

  • PixInsight Addict
  • ***
  • Posts: 202
Re: HaRGBCombination Script
« Reply #98 on: 2013 August 16 04:54:22 »
OK, here you are.
Renamed it to NBRGBCombination to indicate that it is not just Ha anymore. Kept the version numbering to avoid confusion. It is an extension of HaRGBCombination. Installation with the usual way.

My tests with older HaRGB images were ok (tested on 1.8RC7, should be ok with previous also).
Give it a try please, I do not have enough data to test all the cases (and/or contact me with PM to provide me data for tests)

Mind that I had to re-arrange the components on the screen.
Also I unchecked a few of the checkboxes, like the SCRN. I never do SCRN or Color calibration via the script.
MIND the default numbers for bandwidth are based on Baader filters.
Recommendations and feedback are more than welcomed.
« Last Edit: 2013 August 16 07:40:08 by Ioannis Ioannou »
Clear Skies
John (Ioannis)

FSQ106N+Robofocus+QHY-22+SX USB wheel+Baader filters
SX OAG+DSI Pro guiding a NEQ6
PI for the rest :)

Offline Juan Conejero

  • PTeam Member
  • PixInsight Jedi Grand Master
  • ********
  • Posts: 7111
    • http://pixinsight.com/
Re: HaRGBCombination Script
« Reply #99 on: 2013 August 16 11:30:34 »
Hi John,

Nice improvement to the original script. I assume that by "Vicent's method of narrowband combination" you refer to this article. In his article, I think Vicent made a remarkable contribution with the concept of continuum map. Vicent's approach is based on synthesizing a broadband image from the narrowband data. This is an open line of development that we have not yet exploited. We have so many projects, and unfortunately we have so little time and human resources...

Quote
Ha <- (Ha*RGB_bandwidth - RGB*Ha_bandwidth )/(RGB_bandwidth - Ha_bandwidth)

I'm not sure what the intent is with this expression. Essentially, the continuum map is the quotient between the broadband and narrowband images. This is basically a flat fielding operation, where the narrowband image acts like a model of the attenuation applied by the narrowband filter. Put in a more understandable form, the continuum map allows us to isolate just the continuum emission data in the image. So the continuum map in this case would be something simpler such as:

CM = NR( k*Red / Ha )

where k acts like a compensation factor in case it is necessary (k=1 by default), and NR() is a noise reduction operator. Once we have a CM we can synthesize a "clean" broadband channel using Vicent's iterative method, as described in the article. See Figure 8 for example. The crux of this method is avoiding the mix of narrowband and broadband data, which leads to unnecessary noise transfers.

Now the problem with this method is that it is sound for Ha because the red channel can be used as Ha's broadband counterpart with a physical basis, but what happens with OIII, SII, etc? It remains unclear how to build a continuum map for these filters in practice; as I said above this is an open line of development.

Quote
R <- R+(Ha-med(Ha))*HaMultiplier

This simply mixes Ha and red data. By subtracting the median, it is removing Ha's mean background. By multiplying by a scaling factor, it is controlling the amount of Ha that enters the mix. I don't know if anything else was intended, and I don't know also why the median is being subtracted this way.

Quote
Ha <- LinearFit(Ha with R)

This is equalizing the Ha and red images using a linear model, taking red as reference. The linear model assumes that every pixel in both images can be expressed as:

v = B + k*S

where v is the pixel value, B is the mean background, k is a scaling factor and S is the pixel's signal. For correctly calibrated and gradient-free linear images, this is a good model.

Despite these complexities, your version of Silvercup's original script is great and can be very useful. I encourage you to further develop it. Once we test it with 1.8 RC7, it would be a nice addition to the final 1.8.0 release. Just a few suggestions regarding the interface:

- Simplify/organize input controls. Instead of the current stack of "Source NB to ..." items, consider defining three GroupBox controls for the R, G, B narrowband images.

- I would label "Scale" instead of "Multiplication factor".

- When a narrowband component isn't selected, the corresponding numerical items should be disabled.

Also I would rethink the suitability of ColorCalibration. For a narrowband combination, the broadband data should be pre-calibrated.
Juan Conejero
PixInsight Development Team
http://pixinsight.com/

Offline marekc

  • PixInsight Addict
  • ***
  • Posts: 177
Re: HaRGBCombination Script
« Reply #100 on: 2013 August 16 11:36:37 »
I have a question about the NBRGB Combination script:

What should I use for the "White Balance Preview"?

I know that if I were shooting a galaxy, I would simply drag a preview around the galaxy. Pixinsight uses the overall color of a spiral galaxy as the basis for the white balance in Color Calibration.

But for a target with no spiral galaxy, such as a nebula, Pixinsight's Color Calibration routine offers `Structure Detection' as an alternative. In other words, it uses the stars in the image for the white balance. So far, so good.

But if I select the 'Structure Detection' check box in the NBRGB script, it demands that I also select a "White Balance Preview".

What should this "White Balance Preview" be? A preview that includes most of the image?

(I am trying to process an image of the Trifid nebula and the nearby open cluster M21.)

Thanks,

- Marek

Offline Ioannis Ioannou

  • PixInsight Addict
  • ***
  • Posts: 202
Re: HaRGBCombination Script
« Reply #101 on: 2013 August 16 12:48:10 »
Thank you Juan for your contribution on the discussion, I was suspecting that the maths behind the script were not build on rock

I'm not sure what the intent is with this expression. .......
Now the problem with this method is that it is sound for Ha because the red channel can be used as Ha's broadband counterpart with a physical basis, but what happens with OIII, SII, etc? It remains unclear how to build a continuum map for these filters in practice; as I said above this is an open line of development.

Yap, as as I was suspected. But you see, the script produces easily nice results (at least with Ha), so I guess we all got lazy and used it without looking deeper. In any case it is a base, I guess the maths can always be improved. At least there is something we can play with.

Quote
Just a few suggestions regarding the interface:

- Simplify/organize input controls. Instead of the current stack of "Source NB to ..." items, consider defining three GroupBox controls for the R, G, B narrowband images.

Yes, the interface has became clattered and needs a redesign, I tried a few combinations with Groupboxes, but the result was more clattered than this, filling the screen and -as the script is modal- making the preview unusable. I'll try to think something better (ideas also are welcomed).

Quote

- When a narrowband component isn't selected, the corresponding numerical items should be disabled.

Yes, there are a few improvements like this for the UI to make it more intuitive. This was just a quick&dirty hack during a few morning hours of a holiday, just to put the idea on the table and to create something usable fast. Improvements like these can (and will) be done.

Quote

Also I would rethink the suitability of ColorCalibration. For a narrowband combination, the broadband data should be pre-calibrated.

YES, I can not agree more. I did not removed the interface and the routines regarding color calibration and SCRN, but I never understood why they were there at the first place and as the matter of fact, personaly I never used them. On this version I just unchecked them by default to discourage the usage just because they are already checked. Maybe it is good idea to totally remove this part of the script ? People ? ideas ?

Clear Skies
John (Ioannis)

FSQ106N+Robofocus+QHY-22+SX USB wheel+Baader filters
SX OAG+DSI Pro guiding a NEQ6
PI for the rest :)

Offline Ioannis Ioannou

  • PixInsight Addict
  • ***
  • Posts: 202
Re: HaRGBCombination Script
« Reply #102 on: 2013 August 16 12:54:40 »
What should I use for the "White Balance Preview"?

Marek, as you can see at Juan's and my answer above, IMHO the color calibration should not happen with this script.

As to answer your question (OT for the script), you can always use a white reference from another photo (eg a galaxy) - at least this is what I'm doing when I want to balance a photo with nebulae without galaxies.
Clear Skies
John (Ioannis)

FSQ106N+Robofocus+QHY-22+SX USB wheel+Baader filters
SX OAG+DSI Pro guiding a NEQ6
PI for the rest :)

Offline marekc

  • PixInsight Addict
  • ***
  • Posts: 177
Re: HaRGBCombination Script
« Reply #103 on: 2013 August 16 13:09:42 »
Thanks, Ioannis, that helps.

So, just to make sure I'm doing things correctly, here's how I'm using the script:

1) I make an RGB image with ColorCombination.

2) I select that RGB image as the RGB image in the NBRGB script.

3) I have the Ha image open, too, and I select it in the NBRGB script.

4) I make sure the filter bandwidths are correct. (I'm using Baader RGB filters, so I leave the RGB bandwidth at 100nm.)

5) I select previews in the Color Calibration portion of the script, but I leave the `Apply Color Calibration' box UNchecked.

6) I click the `Show RGB' button, and let the script work until I see an RGB image in the preview window.

7) I then click the `Show NBRGB' button, and let the script work until I see the image in the preview window change.

8) I click OK, and now I've got an HaRGB image.

Does that workflow look reasonable?

Thanks,

- Marek

Offline Ioannis Ioannou

  • PixInsight Addict
  • ***
  • Posts: 202
Re: HaRGBCombination Script
« Reply #104 on: 2013 August 16 13:36:50 »
Marek, step 5 is not needed, do not put white or black balance previews if you are not going to do color calibration (which IMHO is recommended). My workflow is :

1) DBE on each channel, RGB combination, dynamic crop, background and color calibration, dynamic alignment with Ha, O3 etc

2) open the script, select the RGB image, select the Ha, O3 narrowband(s), check the bandwidth, 100, 7 and 8.5 are for Baader filters, change accordingly

3) play with the multipliers of Ha, O3, previewing the changes with "Show NBRGB" (and I'm also going back-forth with Show NBr, Show RGB etc to see what it was and how it changes).

As soon as you are happy press OK

Clear Skies
John (Ioannis)

FSQ106N+Robofocus+QHY-22+SX USB wheel+Baader filters
SX OAG+DSI Pro guiding a NEQ6
PI for the rest :)