Author Topic: Issues with the ImageSolver and MergeByCoordinates scripts for a Mosaic  (Read 2910 times)

Offline rlancaste

  • Newcomer
  • Posts: 3
Dear PixInsight Enthusiasts,

I would appreciate your assistance if you can help me with this issue.  I am using the latest PixInsight 1.8.7 and am a pretty experienced user who has been using PixInsight for around 5 years.  But I haven't found an issue like this before.  I am working on a Veil Nebula Mosaic with images taken by my short tube newtonian 6 inch telescope.  I am not finished with my mosaic, but I would like to perfect a good mosaic alignment routine now so that when I am done, I can put it all together easily.  I tried one method that worked pretty successfully which was:

1.  Used the StarAlignment routine in Register/Union mode to build a model of what the mosaic would look like.
2.  Aligned all the images to that model using the StarAlignment routine in Register/Match mode
3.  Merged them all together using GradientMergeMosaic. 

This worked very well with just a couple of minor alignment issues.   But I believe that it would probably be much better to be able to align images using a method that involves plate solving.  I believe it could even correct for any issues with optical distortions in the telescope because it could warp the images as needed to match the astrometric coordinates of the stars.  So I decided to explore another method.

This is a method that I believe should work pretty well:
1.  Use the Image Solver to get the astrometric solution and correct distortions.
2.  Use the AlignByCoordinates tool to register all the images in the mosaic into their proper places based on the astrometric solution.
3.  Use the Gradient Merge Mosaic tool to put it all together.

The issue that I had is that I ran into all sorts of unexpected problems.  I understand the documented limitations in the image solver where it is not a blind solver and needs starting coordinates, so I used astrometry.net to get a solution so the images have coordinates in them to start.  The issues that I found were not the documented ones, instead they were quite unexpected.  I am not sure if I am using something wrong or if there is an issue with the tools somewhere.

Here are the issues that I found:

1.  Astrometry.net uses FITS or TIFF files for its input and output so I had to convert to FITS to start, not XISF.   Bringing the fits file into PixInsight, it complains that "The FITS format does not define an unambiguous orientation of pixel data. The coordinates read on the image may be wrong."  I am not sure if this will cause some of the problems that I observed later so I tried a variety of things to see if it contributed to the issue, but it didn't seem to be a factor.  But note that Astrometry.net cannot use XISF files, so if I have to solve with Astrometry.net, this might be an issue.  I also tried converting the files to XISF files, that doesn't make sense because if the orientation is ambiguous, just changing the file type won't help.

2.  Due to the issue I wrote in #1, I figured that maybe I should be using XISF files to start in my alignment routine.  So I tried solving an image in the PixInsight image Solver using decent starting coordinates.  It solved the image and I saved the file as XISF.  But when I tried to use the image in the AlignByCoordinates tool, I found that the XISF file did not contain the WCS information.  If I instead saved the file in the FITS format, then it DID contain the WCS information.  The same issue happened if I tried to convert a FITS file to an XISF file.  The WCS Information disappeared.  For some reason XISF files do not appear to be saving WCS coordinates.  I thought the goal was to switch over to XISF, but this seems to be a big flaw unless I am missing something.

3.  Another thing that I tried was to load the FITS image solved with Astrometry.net and use the "only optimize the solution" option.  This worked very well for solving the image and correcting distortion using the Pixinsght Image Solver, but when it saved the output files, they were FITS files once again and there didn't seem to be any way to change that.  This is fine if the FITS file format won't cause any problems, but if it will, then that isn't good because you can't select a different output format in PixInsight Image Solver.  It might be good to add the option to save the output files in a different format that doesn't have an "ambiguous orientation" from the image solver.

4.  Another thing that I tried that DID work was to just keep all the images loaded in PixInsight as image views, and they DID keep the WCS information needed by the AlignByCoordinates routine, but this is not a good solution because if you have too many images in your mosaic, you would have to keep a number of large files open in memory in order to make the mosaic. 

5.  And This was the biggest issue.  It didn't matter which method I used for solving the images, Astrometry.net, Astrometry.net augmented with the PixInsight Image Solver, or just the PixInsight Image Solver, nor did it matter if I saved the files, or if I kept them in image views in PixInsight, all the procedures had the same issue when I got to using the AlignByCoordinates routine.  For some reason all of the images were in their proper places in the mosaic, even with mostly correct image orientations, but they were all flipped vertically.  So that the nebula in each image didn't line up properly.  I am not sure if this has something to do with the way I was plate solving images, or something to do with the fact that my telescope is a reflector instead of a refractor. 


So to get around these issues, I had to add a couple of undesirable steps as work-arounds to my procedure.  Here is what I ended up doing that worked:

1.  Plate solve all images in Astrometry.net to get an initial set of coordinates.
2.  Plate solve all images in PixInsight Image Solver clicking the "only optimize the solution" option and letting it do distortion correction.
(NOTE: Leave all images OPEN in views instead of saving the image so that the image doesn't lose its WCS coordinates)
3.  Make a copy of the image views and do a vertical image flip on all images using the "Fast Image Rotation" tool using the mirror vertical option (Note, this will kill the WCS solution data, which is why the copy is needed)
4.  Use the CopyCoordinates script to copy the WCS solution data from the non flipped image to the flipped image
5.  Use the MergeByCoordinates Tool to produce the registered images using the flipped images
6.  Use the Gradient Merge Mosaic tool to put the final image together.

Does anyone have any ideas about these issues?  Am I doing something incorrectly or is there something wrong with the scripts?

Thank you for your assistance,

Rob Lancaster



Offline bulrichl

  • PixInsight Guru
  • ****
  • Posts: 524
Hi Rob,

some questions concerning your issue #5:
- Are your subframes stored as FITS files?
- When you open a subframe in PixInsight, is the image flipped vertically or is it true sided?
- What is your setting in Format Explorer/FITS regarding the Coordinate Origin?

Bernd

Offline Andres.Pozo

  • PTeam Member
  • PixInsight Padawan
  • ****
  • Posts: 927
You have find some of the many issues of the FITS format. Although the FITS format does specifies the vertical orientation of the images (botton-up), many amateur level applications write the images up-bottom. PixInsight lets you to select the behavior: go to "Format Explorer | FITS | Edit Preferences | Miscellaneous options | Coordinate origin" and select the value that works for your images.

If you use astrometry.net to find the coordinates and pixel scale of your images, you can use this as an starting point for ImageSolver. Only, you don't have to select "Only optimize the solution" but do a full calculation. When you have doubts about the vertical orientation of the image you should select in ImageSolver the option "Alignment algorithm=Triangles". Doing this the vertical orientation of the image does not matter. You can use both FITS or XISF as an input and the result can be saved also in both formats.

After solving the images you can use MosaicByCoordinates for aligning them against a common geometry that it is calculated automatically. MosaicByCoordinates works with FITS and XISF.

Offline rlancaste

  • Newcomer
  • Posts: 3
Hi Bernd,

- Are your subframes stored as FITS files?

I actually tried more than one option.  I tried using FITS files, I tried using XISF, and I tried just keeping the images open as views.  The method of storing the subframes didn't seem to affect the final outcome.

- When you open a subframe in PixInsight, is the image flipped vertically or is it true sided?

I don't believe my images are flipped vertically.  They were taken with a reflector, so I could see how it is possible, but I do believe that the images look the same as every other time I have seen the veil.  I could attach a frame if it would help.

- What is your setting in Format Explorer/FITS regarding the Coordinate Origin?

I just checked and it is up-bottom.  I was not aware of this setting.  Perhaps this is the issue?

Thanks,

Rob

Offline rlancaste

  • Newcomer
  • Posts: 3
Hi Andres,

You have find some of the many issues of the FITS format. Although the FITS format does specifies the vertical orientation of the images (botton-up), many amateur level applications write the images up-bottom. PixInsight lets you to select the behavior: go to "Format Explorer | FITS | Edit Preferences | Miscellaneous options | Coordinate origin" and select the value that works for your images.

--Thanks for helping me find the coordinate origin setting. I didn't know about that one. That might be causing my issue.

If you use astrometry.net to find the coordinates and pixel scale of your images, you can use this as an starting point for ImageSolver. Only, you don't have to select "Only optimize the solution" but do a full calculation. When you have doubts about the vertical orientation of the image you should select in ImageSolver the option "Alignment algorithm=Triangles". Doing this the vertical orientation of the image does not matter. You can use both FITS or XISF as an input and the result can be saved also in both formats.

--I was assuming that if I unchecked "only optimize the solution" that it would require me to type in the RA and DEC.  Is this not the case?  If so, how do I indicate that I want to use the WCS coordinates in the image as a starting point?

--thanks for the info about the alignment algorithm, I will try that out.

--I was finding that I could not save the WCS coordinates in an XISF file.  Saving the file did not retain the coordinates.  Is there a setting that would prevent them from being saved?

After solving the images you can use MosaicByCoordinates for aligning them against a common geometry that it is calculated automatically. MosaicByCoordinates works with FITS and XISF.

--Yes this is what I was attempting to do, but I could not get the coordinates into the XISF files, only in the FITS files.

Offline bulrichl

  • PixInsight Guru
  • ****
  • Posts: 524
I suggest you to check whether the subframes (stored by the capturing program as FITS files) are true sided. If this is not the case, change the 'Coordinate Origin' in Format Explorer/FITS. However, if you do that, Master Calibration files have to be prepared again from the existing darks, bias frames, flats, and flat-darks.

If you are using BPP, the correct setting for Coordinate Origin has to be used in 'Global Options' as well (enable or disable 'Up-bottom FITS' accordingly).


Bernd