Author Topic: How to match intensities in a mosaic?  (Read 4337 times)

Offline joelshort

  • PixInsight Addict
  • ***
  • Posts: 260
    • Buckeyestargazer.net
How to match intensities in a mosaic?
« on: 2015 August 28 16:09:34 »
I'm working on a 4 panel mosaic image (HaOIIIRGB).  I have contemplated two processing plans, and need some direction with matching intensities in either plan.

1.  My first plan was to completely process each panel to a complete image and then assemble the mosaic.  In this scenario, how do I accurately match the intensities between the panels?  I can eyeball it but that's not very PI-like.  ;)

2.  My next plan is to create mosaics of each channel and then just treat the mosaic channels like any other single image.  Same question applies, how do I match intensities between the panels in each mosaic?

Most of the reason I'm asking this question is because LinearFit only works between images of identical geometry, which doesn't apply to separate mosaic panels.

Someday I'm actually going to contribute to this forum instead of always asking questions...
Joel Short
www.buckeyestargazer.net
CFF135 f6.7, SV80ST, G3-16200M, QHY163M, QHY183M

Offline msmythers

  • PTeam Member
  • PixInsight Jedi
  • *****
  • Posts: 1178
    • astrobin
Re: How to match intensities in a mosaic?
« Reply #1 on: 2015 August 28 17:23:19 »
Joel

If the panels have the same general look you could use the Statistics tool and AutoHistogram. Pick the image you want to match and use Statistics for the median values of each channel. Then use Autohistogram in the Rational Interpolation (MTF) stretch mode. Using the median values from the one image set the channels in Autohistogram to those values. Apply to the other image. You might need to do a background neutralization afterwards.


Mike

Offline joelshort

  • PixInsight Addict
  • ***
  • Posts: 260
    • Buckeyestargazer.net
Re: How to match intensities in a mosaic?
« Reply #2 on: 2015 August 28 17:54:27 »
Thanks Mike.  On a quick pass that seemed to work pretty well, although the images do have to be VERY similar to start with.  I think that will do the trick.
Joel Short
www.buckeyestargazer.net
CFF135 f6.7, SV80ST, G3-16200M, QHY163M, QHY183M

Offline msmythers

  • PTeam Member
  • PixInsight Jedi
  • *****
  • Posts: 1178
    • astrobin
Re: How to match intensities in a mosaic?
« Reply #3 on: 2015 August 28 19:45:16 »
Joel

Here are those images I showed as a mosaic. I use the autohistogram, image solver script, mosaic by coordinates script and then gradient merge mosaic.

The images. North American http://www.astrobin.com/181244/   Pelican http://www.astrobin.com/200511/

The Mosaic. http://www.astrobin.com/206729/


Mike

Offline RickS

  • PTeam Member
  • PixInsight Jedi
  • *****
  • Posts: 1298
Re: How to match intensities in a mosaic?
« Reply #4 on: 2015 August 28 20:42:40 »
How about using the Frame adaption option in StarAlignment?  It did a good job of matching (linear) mosaic panels the few times I have used it.

Cheers,
Rick.

Offline pfile

  • PTeam Member
  • PixInsight Jedi Grand Master
  • ********
  • Posts: 4729
Re: How to match intensities in a mosaic?
« Reply #5 on: 2015 August 28 21:40:33 »
also check this thread: http://pixinsight.com/forum/index.php?topic=8842.0

there's a script in there made by dnault42 whose purpose is to do the frame adaptation at the linear stage.

rob

Offline dnault42

  • PixInsight Addict
  • ***
  • Posts: 125
Re: How to match intensities in a mosaic?
« Reply #6 on: 2015 August 29 01:01:21 »
In general I do a mosaic for each color channel separately.  So, I take all the red panels and construct that mosaic, then I move to the green, blue, h-alpha, etc.  Once I've completed that I treat it just like a regular image with separate color components.  You can certainly do it the other way, combining all the color channels of each panel first, but I find it more difficult to get all the intensities correct without clipping anything.  I just recently updated my dnaLinearFit script (download here) to handle color, which should make the second method easier.

My script has 2 advantages over using the LinearFit process when dealing with mosaics.  It only uses the areas that overlap to determine the fit (similar to frame adaptation during registration).  It also maintains zero values when scaling the intensities of the data so that GradientMergeMosaic can correctly identify what is valid data and what isn't when combining the mosaic.

The 'Least Squares' method is probably the most robust, but I've gotten good results from the 'Mean / Median' method 95% of the time.  If you have any questions about the script, let me know.

Regards,
David

Offline joelshort

  • PixInsight Addict
  • ***
  • Posts: 260
    • Buckeyestargazer.net
Re: How to match intensities in a mosaic?
« Reply #7 on: 2015 August 29 05:22:10 »
Thanks David, I will definitely give your script a try.  I would definitely prefer to build the mosaic as you describe, a mosaic for each channel and then just treat the image as a regular LRGB image.  However as of yet I have not been successful in matching intensites using the frame adaptation of the star alignment process. 
Joel Short
www.buckeyestargazer.net
CFF135 f6.7, SV80ST, G3-16200M, QHY163M, QHY183M

Offline joelshort

  • PixInsight Addict
  • ***
  • Posts: 260
    • Buckeyestargazer.net
Re: How to match intensities in a mosaic?
« Reply #8 on: 2015 August 29 05:53:47 »
David, I'm sure I'm doing something wrong, but when I try to match 2 panels I get the following error:
*** Error [000]: C:/Users/Joel/Desktop/dnaLinearFit.js, line 132: Error: Image.sample(): coordinate(s) out of range.

I've tried every panel in the 4 panel mosaic I'm working on and no joy.  Just to be clear, I'm trying to match two HA panels side by side with an overlap of about 20%

Also, can the script be "installed" so that it is invoked from the scripts menu, or does it always need to be called with "Execute Script File"?
Joel Short
www.buckeyestargazer.net
CFF135 f6.7, SV80ST, G3-16200M, QHY163M, QHY183M

Offline dnault42

  • PixInsight Addict
  • ***
  • Posts: 125
Re: How to match intensities in a mosaic?
« Reply #9 on: 2015 August 29 09:45:31 »
My first real bug, Yay!  Are the images the same size, meaning have you already registered them for their position in the mosaic?  If so, can you post the panels you are trying to match so I can try them?

As for installing the script, copy it to your PixInsight/src/scripts directory (you may need admin access to put them there), then go to 'SCRIPT->Feature Scripts...' and click 'Add'.  Navigate to the PixInsight/src/scripts directory (or wherever you actually put the script) then hit ok and it will search that path for any new scripts.  Once it find mine it will be added to the menu under 'SCRIPT->Utilities' (it can also be found under the Process Explorer under <Scripts> <Utilities>).

Regards,
David

Offline joelshort

  • PixInsight Addict
  • ***
  • Posts: 260
    • Buckeyestargazer.net
Re: How to match intensities in a mosaic?
« Reply #10 on: 2015 August 29 10:27:29 »
David, no bugs here!  Not surprisingly I just didn't know how to do it.  I thought your script built the mosaic from scratch and did not understand that I first needed to register each panel to an alignment template created with StarAlignment and GradientMergeMosaic.  Once I aligned the panels to the alignment template the script worked beautifully.  There were still slight variations in the background intensity levels of the panels, but I still need to play with the different fit methods (media/mean etc).  Also, the GradientMergeMosaic process left a couple of dark blobs around bright stars, so I'll have to play with GMM or perhaps crop out those stars in one of the panels (does that work?).

Here's the first pass result using your script and just a autoSTF:
Joel Short
www.buckeyestargazer.net
CFF135 f6.7, SV80ST, G3-16200M, QHY163M, QHY183M

Offline dnault42

  • PixInsight Addict
  • ***
  • Posts: 125
Re: How to match intensities in a mosaic?
« Reply #11 on: 2015 August 29 10:39:06 »
Joel,

Ok, glad it's working.  Cropping out the stars usually works to remove the darkening around bright stars near the edges of the panels.  I've had a few cases where the crop itself caused secondary issues, but that's pretty rare.  I posted some PixelMath on how to do the crop in the thread that Rob linked to.

That mosaic is looking excellent!

Regards,
David

Offline joelshort

  • PixInsight Addict
  • ***
  • Posts: 260
    • Buckeyestargazer.net
Re: How to match intensities in a mosaic?
« Reply #12 on: 2015 August 29 10:48:34 »
So I'm curious what preparations you make to the individual panels before merging together.  I'm assuming DBE before merge.  Do you also do any linear noise reduction before merging? 

In other words, at what point in your processing do you merge the panels together to form the separate channel mosaics?
Joel Short
www.buckeyestargazer.net
CFF135 f6.7, SV80ST, G3-16200M, QHY163M, QHY183M

Offline joelshort

  • PixInsight Addict
  • ***
  • Posts: 260
    • Buckeyestargazer.net
Re: How to match intensities in a mosaic?
« Reply #13 on: 2015 August 29 10:54:53 »
Another question, does the script attempt to match intensities across the whole image or just in the overlap?  Would defining previews of the overlap change anything?
Joel Short
www.buckeyestargazer.net
CFF135 f6.7, SV80ST, G3-16200M, QHY163M, QHY183M

Offline dnault42

  • PixInsight Addict
  • ***
  • Posts: 125
Re: How to match intensities in a mosaic?
« Reply #14 on: 2015 August 29 11:06:43 »
The script looks for pixels that are non-zero in both images and uses those to determine the linear fit, so defining previews wouldn't change anything.  Once the linear fit parameters are determined the fit is applied to the whole image not just the overlapping area.

Regards,
David