Making astronomical mosaics is a difficult task. There can be intensity and gradient differences that make the seams visible. Even when the intensities are matched you may find there are noise profile differences. Luckily PixInsight has many tools that help with creating seamless mosaics.
My preference is do the mosaics in linear form that way a any non-linear stretching is always consistent across the panels. This causes some complications like pinching artifacts around bright stars on the seams, but I generally find it preferable to dealing with data that has different stretches applied.
Thanks to Anis for allowing me to use his Cygnus Region data as the basis for this tutorial.
The Mosaic Processing Flow
The general process goes something like this:
- Crop out low signal areas
- Even out background gradients
- Organize Panels
- Estimate area covered
- Create Catalog Star image
- Register panels to Catalog Star image
- Adjust the intensity of each panel so they match up
- Crop the panels down if necessary
- GradientMergeMosaic test
- Crop out stars causing pinching
- Repeat the last to steps until you have a clean results
Cropping out Low Signal Areas
The first thing we need to do is make sure to crop out any empty regions and low signal areas. Bring up the DyanimcCrop process and click and drag a box in one of the panels covering most of the image. Now zoom at a scale of 4:1 or something like that and check out the corners (see Figure 1).
Move your cursor to the corner of the box you’ve drawn and you can click and drag it to a new position. You can also rotate the box, adjust one edge at a time, etc. In this image the first row of pixels is all black and several pixels below that have a higher noise profile compared to the remainder of the image so we are going to adjust the crop box to just below that (see Figure 2).
Once you are satisfied that you are selecting the best parts of the image click the check-mark icon on the DynamicCrop process to apply it. This procedure needs to be done on every mosaic panel to make sure that the seams are as clean as possible.
Evening out Background Gradients
If you want the best results you will need to make sure that the backgrounds of your images are as even as possible. This can be difficult if you have a lot of nebulosity in your images. I’ve described two methods for doing this in previous tutorials. You can use a synthetic flat or DynamicBackgroundExtraction (described fairly early in the M42 tutorial). There’s one other method I haven’t talked about, AutomaticBackgroundExtraction (ABE). In general when I use this tool, I use the default setting except that I enable the correction method ‘Subtraction’. I’ll run a pass to check what the background model looks like. If it looks ok, then I’ll enable the ‘Discard background model’ and ‘Replace target image’ options so it updates the current image (see Figure 2a).
Whichever method you choose, repeat the process on each panel so that the backgrounds are as even as possible. This will help the GradientMergeMosaic tool later on and give you a smoother looking result.
If you have a lot of panels it really helps to organize them spatially to get an idea of how they are laid out and to gather some information about the field of view they cover. I generally rename the panels t00, t01, etc. to make it easier to keep track of which panel goes where. Figure 3 shows me moving one image over another to get an idea of how they line up. In order to see the frame behind the one you are moving, the translucent options need to be enabled in the Global Preferences under Special GUI Effects.
Estimating the Area Covered
If you just have a couple panels you can register them to each other, but for multi-panel mosaics I prefer to use a synthetic star field and register each of the panels to that. In order to generate that star field we need to know approximately where the center of the field, what the image scale is and how much sky is covered.
I know that Anis used a Takahashi Epsilon 130d and a KAF-8300 based sensor. This results in an image scale of around 2.59 arc-seconds per pixel. There are many calculators available to do estimate this, but in this case, I’m going to use PixInsights plate solving and image annotation script to get a more accurate measurement of the image center and image scale. Go to SCRIPTS->Image Analysis->ImageSolver and select the search option. This will pop up a new form which where you can search for an object. Either put in the primary subject of your image or find something that is close and enter it. Hit OK and this will populate the coordinate information in the original form. You can also use a planetarium program to estimate a central location. Since NGC6888 is off-center in Anis’ image I used the second method and entered an approximate center manually. I also populated the focal length and pixel size of Anis’ scope and camera (you can also just put in the image scale directly if you know it). Figure 4 shows the settings I used. Clicking OK will run the script and if everything goes well it will update the image with information about how it maps to the sky.
After the plate solving script completes you should see something like Figure 5 in the console. This shows information about the image scale (Resolution), rotation, true focal length, image center, field of view, etc. This information is also populated in the FITs header of the image so other scripts can reference it.
Now that the image has been updated with its plate information we can run the Image Annotation script to estimate the center of the field of view of the entire mosaic. Go to SCRIPTS->Render->ImageAnnotation and you should see something like Figure 6.
You can select what layers you want, but primarily what we want is the ‘Grid’ option. You should also increase the ‘Grid density’ option so that we can use the grid lines as a reference for the frame center. This will vary based on your image size. For Anis’ image I used a grid density of 20. Since the data is linear, make sure the ‘Apply STF before annotation’ option is on. This will generate a new image populated with a grid showing the RA and DEC values. Using the same technique as we did above dragging the image over the other panels we can estimate where the center of the total field of view is (see Figure 7).
Based on the above I estimated that the center of the field for these two images was: 20:14:35, 38°50’48” N. From the plate solving we also know that the field is rotated -84.17 degrees and the image scale is 2.629″/px.
Create Synthetic Star Field
One of the reasons I use this method is because it gives you control over the field curvature present in all optical systems and allows you to setup a map everything to a particular projection method. The CatalogStarGenerator script used Gnomonic by default, but other methods are possible. For this example I will use the Gnomonic projection method.
Go to SCRIPTS->Render->CatalogStarGenerator which will bring up the script we will use to generate our star field. Each of the panels in this data set are about 3320 pixels across and 2500 pixels high. We have a little vertical offset and probably something like a 15% horizontal overlap. This means, in terms of pixels, the field covers approximately 6142 (2*3320 – 0.15*3320 = 6142) horizontal pixels and 2700 vertical pixels. I usually pad this out a bit to be sure that I am covering the field adequately (I decided on 6500×3000 for this data). Figure 8 shows the settings I used for the Catalog Star Generator script. You can see where I populated the other information we gathered. Figure 9 shows the synthetic star field on top of the the other two images so you can see approximately how they line up.
Registering the Panels
Now that we have a single reference image we can register each of the panels to it. Bring up the StarAlignement process. For the reference image, switch it to ‘View’ and then select the CatalogStars image. Because the projection model may not match the curvature of your optical system I suggest turning on 2-D Surface Splines and Distortion correction. This will help make the mosaic more seamless. Leave the ‘Working mode’ set to ‘Register/Match Images’, just as if you were doing normal star alignment. You may need to increase the RANSAC tolerance to deal with the differing curvatures. Also, to make the registration more robust and a bit faster it helps to turn on the ‘Restrict to previews’ option and create a preview that covers a bit more than the area of the panel you will be registering. Do not use the ‘Frame adaptation’ option, we will deal with intensity matching separately. The rest of the settings should be similar to what you normally use. For example, I am going to register the left panel first, so I created a preview in the CatalogStars image that covered top to bottom, all the way from the left to a little past the middle (see Figure 10).
Figure 11 shows the full set of StarAlignment settings I used for Anis’ data. Drag the ‘New Instance’ icon (the small triangle on the lower left) from the StarAlignment process to the left image panel (which I called ‘t1’). You should get a new registered image that looks something like Figure 12. Repeat the process for all panels, adjusting the preview appropriately.
The next thing we need to do is match the intensities of the two images so that GradientMergeMosaic (GMM) can do a better job at merging the panels. Normally I would use the LinearFit process for this, but it has one big issue. When it adjusts the image it can raise the background level as part of the fit. This does not play well with GMM which requires the parts of the image that do not contain data to be entirely black. In order to get around this I wrote my own linear fit script which you can download here (click the link, then click the download button – do not copy and paste the text). To install it, copy it into your PixInsight/src/scripts folder then go to SCRIPTS->’Feature Scripts…’ and click ‘Add’ button. It will ask you for the directory, point it to your PixInsight/src/scripts folder and hit OK. It should find the script and make it available in the SCRIPT menu. It will show up under Utilities->’dnaLinearFit 0.1′.
Before we launch it, let’s make sure the images have the same ScreenTransferFunction (STF) stretch applied. By the way, all the images in this tutorial have had an STF auto stretch applied so the data is visible since the data is still linear. Once you have STF process up, apply a stretch to the right panel, then drag the ‘New instance’ icon from the STF window to the left panel. This will apply the same STF stretch to the left panel. In my case the left panel is much brighter so it shows up as almost white. This isn’t really a problem as STF does not modify the data, it just alters how it is displayed.
Now we are going to adjust the left panel so that it has the same intensity profile as the right panel where the images overlap. Bring up dnaLinearFit and select the right panel as the ‘Reference View’ and the left panel as the ‘Target View’ (see Figure 13) and hit OK. You should see the left panel show up clearly now.
Cropping the images down
Now that we have intensity matched registered panels, let’s make a first pass attempt at a mosaic and use it to crop the data before feeding it to GMM. Bring up PixelMath and we are going to a maximum function between all the panels (see Figure 14). Hit the ‘Apply’ button it will generate a new image. With Anis’ narrowband data this almost look perfect just as it is, but there are some minor seams, so we’ll continue on (see Figure 15).
Now bring up the DynamicCrop process and select the the portion of images you want to be in your final image. GMM can have problems with corners and black around the image so I general crop into an area where data exists everywhere. You don’t need to crop that image, instead drag the ‘New Instance’ icon from DynamicCrop to the PI desktop to save that crop. That crop can now be applied to all the panels by dragging the desktop icon to each image. After applying the crop to all panels you should have something that looks like this Figure 16.
Save the panels to disk now as GMM cannot reference views in PI.
Gradient Merge Mosaic
Bring up the GradientMergeMosaic process and add the files that we’ve registered, adjusted and flattened. Generally I use all of the default settings so you can just click the ‘Apply Global’ button (see Figure 17). It might take a little while but eventually you will get two images, one will be the completed mosaic and the other will be the mask, showing how it merged the panels.
Cropping Out ‘Pinched’ Stars
Anis’ data came out perfect, which is a bit disappointing, because I found no issues around any of the brighter stars. However, for completeness sake, I’m going to pretend this happened and show you how I deal with them. Bring up PixelMath and reset it to defaults (the X looking icon in the lower right), then put in this expression: iif(x()>2659 && x()<2671 && y()>2304 && y()<2320, 0, $T). The x & y coordinates in there are the values around a bright star I found on the edge of one of the panels. They mark the bounds of the star with the x ranging from 2659 to 2671 and the y ranging from 2304 to 2320. I just move my cursor around the offending star and watch the xy values listed on the bottom bar of the PI window to find the coordinates. Figure 19 shows a zoomed in image of the right panel around the star before and after applying pixel math to it.
After removing any stars near the edge of a panel that is showing pinching in the final mosaic, save the image again and then re-run GMM. Keep doing this until you don’t see any artifacts around stars. The last pass with no artifacts will be your final mosaic.
I hope you find this tutorial useful.