Author Topic: AlignByCoordinates  (Read 21973 times)

Offline Andres.Pozo

  • PTeam Member
  • PixInsight Padawan
  • ****
  • Posts: 927
AlignByCoordinates
« on: 2013 June 23 12:04:10 »
The alignment of images is a basic tool for processing of astronomical images. PixInsight has an excellent tool (StarAlignment) for aligning images that works comparing the overlapping areas between the target image and a reference image and trying to find a match between them. Then computes a lineal transformation that converts the geometry of the target image so that it is similar to the reference image.

This usually works very well but it has a few limitations:
  • When the images to align have different geometric distortions StarAlignment can not align them because there is not a lineal transformation between them. This usually happens in images taken with short focal lengths.
  • When building mosaics, StarAlignment can only match the images when there is a big enough overlapping area. For example, it can not align images from the segmented sensors of professional telescopes.
  • When building mosaics, StarAlignment aligns the images by pairs. When a mosaic is formed by many tiles the process is prone to mismatchings caused by accumulating errors.

AlignByCoordinates tries to solve this shortcomings using a different approach to the alignment: Instead of matching an image against other, it requires that the images are plate solved. Knowing the coordinates of each pixel of the image the script can reproject them so the geometries of the images are compatible.

AlignByCoordinates can cope with two kind of geometric distortions:
  • Projection distortions: When two images are not centered in the same point they have different projections. The difference in the projections causes that there is not a lineal transformation between them. This effect is stronger in images with short focal length.
    The following animation shows an example of this effect. The images have been generated from catalog data and the only geometric distortions are caused by the projection. As can be seen in the animation, the Orion asterism has different distortions in each frame.

  • Geometric optical aberrations: The plate solving of astronomical images is usually done supposing that the optical system can be modeled by a  Gnomonic projection.
    However, many lenses or telescopes don't follow strictly this projection. The images from these optical systems can not be solved with high accuracy using only lineal polynomials. ImageSolver and ManualImageSolver can use higher degree polynomials to model the geometric distortions. AlignByCoordinates can use the distortion model generated by the plate solving process for fixing it when aligning images with different distortions.
As a result, AlignByCoordinates can be used for generating wide field mosaics where the tiles have little or no overlapping and when the tiles have strong distortions caused by short focal lenses.

The instructions for using this script are in this PDF: AlignByCoordinates.pdf. The contents of this PDF will be available as the online help of the script when it is distributed with PixInsight.
The following animation is used in the documentation of the script but it doesn't work in the PDF:


The following video shows the four corners and the center of 12 images aligned with AlignByCoordinates. The images were taken with 17mm optics and have heavy distortions:
http://www.youtube.com/watch?v=ARiKCITz1lI


UPDATED VERSION 0.2
« Last Edit: 2013 June 24 15:23:28 by Andres.Pozo »

Offline sreilly

  • PixInsight Padawan
  • ****
  • Posts: 791
    • Imaging at Dogwood Ridge Observatory
Re: AlignByCoordinates
« Reply #1 on: 2013 June 23 12:44:49 »
This looks great but when I try to download any program to un-compress the file ESET NOD32 (my antivirus software) goes crazy. Is it possible to post a standard .zip file?

Thanks,
Steve
www.astral-imaging.com
AP1200
OGS 12.5" RC
Tak FSQ-106ED
ST10XME/CFW8/AO8
STL-11000M/FW8/AO-L
Pyxis 3" Rotator
Baader LRGBHa Filters
PixInsight/MaxIm/ACP/Registar/Mira AP/PS CS5

Offline georg.viehoever

  • PTeam Member
  • PixInsight Jedi Master
  • ******
  • Posts: 2132
Re: AlignByCoordinates
« Reply #2 on: 2013 June 23 13:35:15 »
There are a lot of "variants" of 7zip that are used to transport viruses. Try the official download at http://www.7-zip.org/ of this excellent tool.
Georg
Georg (6 inch Newton, unmodified Canon EOS40D+80D, unguided EQ5 mount)

Offline sreilly

  • PixInsight Padawan
  • ****
  • Posts: 791
    • Imaging at Dogwood Ridge Observatory
Re: AlignByCoordinates
« Reply #3 on: 2013 June 23 14:08:54 »
Thanks, that worked great.

Steve
www.astral-imaging.com
AP1200
OGS 12.5" RC
Tak FSQ-106ED
ST10XME/CFW8/AO8
STL-11000M/FW8/AO-L
Pyxis 3" Rotator
Baader LRGBHa Filters
PixInsight/MaxIm/ACP/Registar/Mira AP/PS CS5

Offline sreilly

  • PixInsight Padawan
  • ****
  • Posts: 791
    • Imaging at Dogwood Ridge Observatory
Re: AlignByCoordinates
« Reply #4 on: 2013 June 23 14:27:51 »
Now that they are unzipped  do I just place them in the PI Scripts folder or a new sub-folder under Scripts?

Thanks again,
Steve
www.astral-imaging.com
AP1200
OGS 12.5" RC
Tak FSQ-106ED
ST10XME/CFW8/AO8
STL-11000M/FW8/AO-L
Pyxis 3" Rotator
Baader LRGBHa Filters
PixInsight/MaxIm/ACP/Registar/Mira AP/PS CS5

Offline Andres.Pozo

  • PTeam Member
  • PixInsight Padawan
  • ****
  • Posts: 927
Re: AlignByCoordinates
« Reply #5 on: 2013 June 23 14:54:08 »
Now that they are unzipped  do I just place them in the PI Scripts folder or a new sub-folder under Scripts?

Thanks again,
You have to unzip all the files in any directory and then register this directory with "SCRIPT / Feature scripts / Add".

Offline sreilly

  • PixInsight Padawan
  • ****
  • Posts: 791
    • Imaging at Dogwood Ridge Observatory
Re: AlignByCoordinates
« Reply #6 on: 2013 June 23 16:05:37 »
Got it thanks, I remember now. It's a bear getting old!

Steve
www.astral-imaging.com
AP1200
OGS 12.5" RC
Tak FSQ-106ED
ST10XME/CFW8/AO8
STL-11000M/FW8/AO-L
Pyxis 3" Rotator
Baader LRGBHa Filters
PixInsight/MaxIm/ACP/Registar/Mira AP/PS CS5

Offline tommy77

  • Newcomer
  • Posts: 1
Re: AlignByCoordinates
« Reply #7 on: 2013 June 24 04:48:00 »
Hello,

if I want to run the script, this error message comes

Processing script file: C :/ Program Files / PixInsight / src / scripts / AdP / AlignByCoordinates.js
Error ***: C :/ Program Files / PixInsight / src / scripts / AdP / AlignByCoordinates.js, line 54: include file not found: pjsr / SectionBar.jsh

What can it be?

Best regards,
Thomas

Offline Andres.Pozo

  • PTeam Member
  • PixInsight Padawan
  • ****
  • Posts: 927
Re: AlignByCoordinates
« Reply #8 on: 2013 June 24 06:05:45 »

Hello,

if I want to run the script, this error message comes

Processing script file: C :/ Program Files / PixInsight / src / scripts / AdP / AlignByCoordinates.js
Error ***: C :/ Program Files / PixInsight / src / scripts / AdP / AlignByCoordinates.js, line 54: include file not found: pjsr / SectionBar.jsh

What can it be?

Best regards,
Thomas

This script requires PixInsight v1.8RC7. You probably have a previous version.

Offline sreilly

  • PixInsight Padawan
  • ****
  • Posts: 791
    • Imaging at Dogwood Ridge Observatory
Re: AlignByCoordinates
« Reply #9 on: 2013 June 24 13:52:28 »
I read through the reference file and tried aligning images taken last night of the Moon. This is with a 12.5" RC @f/9 and a STL-11000M camera using my Ha filter. Now this didn't work as expected as the images all have the coordinates in the FITS header as copied from MaxIm:

SIMPLE     = T / file does conform to FITS standard             
BITPIX     = 16 / number of bits per data pixel                 
NAXIS      = 2 / number of data axes                           
NAXIS1     = 4008 / length of data axis 1                         
NAXIS2     = 2672 / length of data axis 2                         
EXTEND     = T / FITS dataset may contain extensions           
COMMENT      FITS (Flexible Image Transport System) format is defined in 'Astronomy
COMMENT      and Astrophysics', volume 376, page 359; bibcode: 2001A&A...376..359H
BZERO      = 32768 / offset data range to that of unsigned short   
BSCALE     = 1 / default scaling factor                         
PROGRAM    = 'PixInsight 01.08.00.1015 RC7' / Software that created this HDU       
COMMENT      PixInsight Class Library: PCL 02.00.02.0589                             
COMMENT      FITS module version 01.00.14.0228                                       
COLORSPC   = 'Grayscale'          / PCL: Color space                               
RESOLUTN   = 72. / PCL: Resolution in pixels per resolution unit 
RESOUNIT   = 'inch    '           / PCL: Resolution unit                           
DATE-OBS   = '2013-06-24T04:15:34' / YYYY-MM-DDThh:mm:ss observation start, UT     
EXPTIME    = 0.07 / Exposure time in seconds                       
EXPOSURE   = 0.07 / Exposure time in seconds                       
CCD-TEMP   = -19.9771007366559 / CCD temperature at start of exposure in C     
XPIXSZ     = 9. / Pixel Width in microns (after binning)         
YPIXSZ     = 9. / Pixel Height in microns (after binning)       
XBINNING   = 1. / Binning factor in width                       
YBINNING   = 1. / Binning factor in height                       
XORGSUBF   = 0. / Subframe X position in binned pixels           
YORGSUBF   = 0. / Subframe Y position in binned pixels           
READOUTM   = 'Normal  '           / Readout mode of image                         
FILTER     = 'Ha      '           / Filter used when taking image                 
IMAGETYP   = 'Light Frame'        / Type of image                                 
OBJECT     = 'Moon1   '                                                           
OBJCTRA    = '18 54 57'           / Nominal Right Ascension of center of image     
OBJCTDEC   = '-19 07 18'          / Nominal Declination of center of image         
OBJCTALT   = '28.0735 '           / Nominal altitude of center of image           
OBJCTAZ    = '152.0529'           / Nominal azimuth of center of image             
OBJCTHA    = '-1.7301 '           / Nominal hour angle of center of image         
PIERSIDE   = 'WEST    '           / Side of pier telescope is on                   
SITELAT    = '37 48 41'           / Latitude of the imaging location               
SITELONG   = '-78 23 51'          / Longitude of the imaging location             
JD         = 2456467.67747685 / Julian Date at start of exposure               
JD-HELIO   = 2456467.68324002 / Heliocentric Julian Date at exposure midpoint 
AIRMASS    = 2.11486317809478 / Relative optical path length through atmosphere
FOCALLEN   = 2877. / Focal length of telescope in mm               
APTDIA     = 317.5 / Aperture diameter of telescope in mm           
APTAREA    = 79173.0458121747 / Aperture area of telescope in mm^2             
EGAIN      = 0.829999983310699 / Electronic gain in e-/ADU                     
SWCREATE   = 'MaxIm DL Version 5.24 130927 1V9AM' / Name of software that created 
SBSTDVER   = 'SBFITSEXT Version 1.0' / Version of SBFITSEXT standard in effect     
HISTORY      Dark subtraction (Simple Auto-dark)                                     
CALSTAT    = 'D       '                                                           
PEDESTAL   = -100. / Correction to add for zero-based ADU           
TELESCOP   = '        '           / telescope used to acquire this image           
INSTRUME   = 'SBIG STL-11000 3 CCD Camera w/ AO'                                   
OBSERVER   = '        '                                                           
NOTES      = '        '                                                           
FLIPSTAT   = '        '                                                           
SWOWNER    = 'Steven J Reilly'    / Licensed owner of software                     
INPUTFMT   = 'FITS    ' /          Format of file from which image was read       

What I have is 10 images taken with moon in about 1/2 the frame height  for the top and 10 frames with the lower 1/2 of Moon. Aligned using PI without issue using StarAlignment. When I load them in the script I get an error as seen in the uploaded picture.

Not sure if I'm using this script properly or not. MS-ICE did  make a nice mosaic without issue but I'd rather see this work in PI.

Thanks,
Steve
www.astral-imaging.com
AP1200
OGS 12.5" RC
Tak FSQ-106ED
ST10XME/CFW8/AO8
STL-11000M/FW8/AO-L
Pyxis 3" Rotator
Baader LRGBHa Filters
PixInsight/MaxIm/ACP/Registar/Mira AP/PS CS5

Offline Andres.Pozo

  • PTeam Member
  • PixInsight Padawan
  • ****
  • Posts: 927
Re: AlignByCoordinates
« Reply #10 on: 2013 June 24 14:59:45 »
The images have to be solved using the WCS convention. You can do this in PixInsight using the scripts ImageSolver or ManualImageSolver. There are also other programs (as PinPoint) that can do it.

The WCS convention is described in this page:http://fits.gsfc.nasa.gov/fits_wcs.html
Your image hasn't the keywords CTYPE1, CTYPE2, CRPIX1, CRPIX2, CRVAL1, CRVAL2, CD1_1, CD1_2, CD2_1, CD2_2. The keywords that the image currently has are not enough to fully describe the geometry of the image.

Offline Andres.Pozo

  • PTeam Member
  • PixInsight Padawan
  • ****
  • Posts: 927
Re: AlignByCoordinates
« Reply #11 on: 2013 June 24 15:25:51 »
I have updated in the first message the version of the script. It had a silly error that prevented starting the script.

Offline sreilly

  • PixInsight Padawan
  • ****
  • Posts: 791
    • Imaging at Dogwood Ridge Observatory
Re: AlignByCoordinates
« Reply #12 on: 2013 June 24 15:48:16 »
That clears up the error but It's not writing any output files now.

-Thanks
Steve
www.astral-imaging.com
AP1200
OGS 12.5" RC
Tak FSQ-106ED
ST10XME/CFW8/AO8
STL-11000M/FW8/AO-L
Pyxis 3" Rotator
Baader LRGBHa Filters
PixInsight/MaxIm/ACP/Registar/Mira AP/PS CS5

Offline Andres.Pozo

  • PTeam Member
  • PixInsight Padawan
  • ****
  • Posts: 927
Re: AlignByCoordinates
« Reply #13 on: 2013 June 25 01:14:04 »
That clears up the error but It's not writing any output files now.

-Thanks
Could you post a copy of the contents of the console? Also one of the images would be very helpful. You can use dropbox or similar to upload it.

Keep in mind that this script is designed for deep sky images. It probably won't work for stitching mosaics of the moon or landscapes.

In any case, the process for creating a mosaic would be this:
  • Calibrate, register and integrate the subframes of each tile.
  • Crop the tiles in order to remove the areas at the borders that were no covered by all the subframes.
  • [Optional] If the tiles have gradients you should remove them using DBE.
  • If the tiles are RGB you should do a color calibration.
  • Solve the tiles using ImageSolver or ManualImageSolver. The quality of the alignment of the tiles depends on this process.
  • Execute AlignByCoordinates using the mode "Create mosaic" and select as reference image the tile closest to the center .
  • Merge the aligned tiles using a suitable process. I recommend GradientMergeMosaic.

I will add this to the documentation of the script.

Offline Andres.Pozo

  • PTeam Member
  • PixInsight Padawan
  • ****
  • Posts: 927
Re: AlignByCoordinates
« Reply #14 on: 2013 June 25 04:10:18 »
I have just finishd an example of aligning and integrating 10 images taken with a 105mm lens and a camera with a big sensor. The images were taken with a dithering of several tens of pixels. Since the images have moderate distortions in the corners the dithering causes misalignment of the stars.

Using ImageSolver for solving the images with 5th degree polynomials and AlignByCoordinates, the result of the integration is better than when it is done using StarAlignment.

This animation compares the right-bottom corners of the result of the integration of the images aligned with StarAlignment and AlignByCoordinates:


This is the result of the script FWHMEccentricity (by Mike Schuster):


This is the distortion map of one of the images: