Aligning images

566 views
Skip to first unread message

Philip Bergen

unread,
May 27, 2013, 12:10:16 AM5/27/13
to astro...@googlegroups.com
Aloha,
I'm sure this has been asked before, but I fail to find the answer, so please, help me out.
How do I align two images solved and tagged by astrometry.net?

Case 1: Images are approximately the same with slight differences in offset and rotation
Case 2: Images are overlapping but different offset, rotation and magnification

I know basic trigonometry, but don't know what the transformation matrix header info implies or what the SIP polynomials convey.
I assume that can be used to determine the orientation of the image, but how to get from there to "rotate by x rad"?

Thanks,
// Phil

Robert Siverd

unread,
May 27, 2013, 2:54:08 AM5/27/13
to astro...@googlegroups.com
Hi Phil,


On Sunday, May 26, 2013 11:10:16 PM UTC-5, Philip Bergen wrote:
Aloha,
I'm sure this has been asked before, but I fail to find the answer, so please, help me out.
How do I align two images solved and tagged by astrometry.net?

Case 1: Images are approximately the same with slight differences in offset and rotation
Case 2: Images are overlapping but different offset, rotation and magnification

What exactly do you mean by "align" here?  Do you want to resample one image onto the pixel positions of another (i.e., image registration)?  Or do you want to merge the two into a new image that contains all the pixels from both?

SWarp may do what you want, but I'm not sure if it understands the -SIP distortion convention (last time I tried [long ago], it did not). It may work fine with a modern version of WCSLIB.
SWarp:  http://www.astromatic.net/software/swarp
WCSLIB:  http://www.atnf.csiro.au/people/mcalabre/WCS/
 
I know basic trigonometry, but don't know what the transformation matrix header info implies or what the SIP polynomials convey.

SIP polynomials tell you about distortion in the image. Distortion essentially means that your pixels are not all the same size/shape/orientation in sky coordinates. Googling "SIP distortion" (sans quotes) will take you to the standard.

See here:
http://fits.gsfc.nasa.gov/registry/sip.html
 
I assume that can be used to determine the orientation of the image, but how to get from there to "rotate by x rad"?

If your image has significant distortions and shifts, "shift and rotate" will not align them (you need to resample). Orientation (i.e., the direction of North in pixel coordinates) can vary significantly across wide FOVs and thus may not be well-defined. As an extreme case, consider an image centered on the north celestial pole: North points "right" on the left side of the image but points left on the right side.

Hope this helps,
Rob

Philip Bergen

unread,
May 27, 2013, 3:03:38 AM5/27/13
to astro...@googlegroups.com
Hi Rob,
Thanks for the quick reply. That explains the polynomials, I'll have to look up how to interpret them.
With align I mean make into one. Use the combined information of multiple images to produce one, richer in content. 
Most stacking just uses a process of picking out manually two stars and then just rotates and rescales.
I would much rather have AM.net accurately identify the starfield for a much more accurate resampling and stacking.
I'm sure there is a library or program that does this, hardly can I be the first to have that thought.

So I found astrodrizzle which seems to do that (and remove cosmic rays, not quite as useful down here as it is in space),
but only for images captured by the Hubble Space Telescope. I was hoping enriching the fits files with AM.net would feed the astrodrizzle library enough information to do its thing. Alas it assumes a large array of headers are present, as I'm sure they are should you put your telescope in higher orbit than a few feet... 

I will look at the libs and SIP distortion. Thanks!

// Phil

Robert Siverd

unread,
May 27, 2013, 4:05:30 AM5/27/13
to
Hi Phil,

I think I'm working on a similar problem (resampling wide-field images onto all-sky projection). Do please post results if and as you are successful. I've written some simplistic software along these lines, but it would be much more convenient if established tools like SWarp were able to properly handle SIP distortion.


On Monday, May 27, 2013 2:03:38 AM UTC-5, Philip Bergen wrote:
Hi Rob,
Thanks for the quick reply. That explains the polynomials, I'll have to look up how to interpret them.
With align I mean make into one. Use the combined information of multiple images to produce one, richer in content. 
Most stacking just uses a process of picking out manually two stars and then just rotates and rescales.
I would much rather have AM.net accurately identify the starfield for a much more accurate resampling and stacking.

If I understand correctly, SWarp does much of what you want (assuming it understands SIP). I suggest you check that out. The user manual is extremely informative.

I'm sure there is a library or program that does this, hardly can I be the first to have that thought.

The idea isn't new. The problem is that no distortion standard exists for WCS. Instead, there are several local (in some cases, project-specific) conventions that are registered with the FITS folks. The various conventions are not necessarily interoperable. Most of them are pretty new. Various projects have used different conventions probably for implementation convenience.

The SIP convention (Simple Imaging Polynomial, originally Spitzer Imaging Polynomial) employed by astrometry.net is widely used but not ubiquitous. The TPV convention was used for CFHT and will be used with NOAO's Dark Energy Camera. Others exist and are actively used. The NASA FITS WCS page lists the core "standard" WCS components as well as the registered (non-standard) distortion conventions (how they work and who uses what):
http://fits.gsfc.nasa.gov/fits_wcs.html

This is *definitely* worth a look and ought to better explain the current quagmire.

Numerous WCS libraries do exist, but they don't all support every distortion convention. Different software programs rely on different libraries, so some detective work may be needed to figure out which programs support what conventions. Last I checked (years ago), SWarp and other Astromatic tools were built against WCSLIB, which at the time only supported TPV (no SIP). WCSLIB may have incorporated SIP since, in which case tools that use it (including SWarp) will inherit this ability.

-Rob

Philip Bergen

unread,
May 27, 2013, 4:36:11 AM5/27/13
to astro...@googlegroups.com
Hi Rob,
Awesome! Better chance for both of us! :)
I installed swarp, not been updated since 2009. Seems to understand the WCS put in there by AM.net though. It put together an image for me.
Problem is I don't know what to do with it. What's a good FITS viewer? I have a kinda crappy one (fv).
It just shows as white until I changed the colors to histo equalize. I get a grainy black and white image, that to some extent resemble my motif. 
How do I get from there to a color image of some fidelity?

// Phil

On Monday, May 27, 2013 1:04:02 AM UTC-7, Robert Siverd wrote:
Hi Phil,

I think I'm working on a similar problem (resampling wide-field images onto all-sky projection). Do please post results if and as you are successful. I've written some

On Monday, May 27, 2013 2:03:38 AM UTC-5, Philip Bergen wrote:
Hi Rob,
Thanks for the quick reply. That explains the polynomials, I'll have to look up how to interpret them.
With align I mean make into one. Use the combined information of multiple images to produce one, richer in content. 
Most stacking just uses a process of picking out manually two stars and then just rotates and rescales.
I would much rather have AM.net accurately identify the starfield for a much more accurate resampling and stacking.
If I understand correctly, SWarp does much of what you want (assuming it understands SIP). I suggest you check that out. The user manual is extremely informative.

I'm sure there is a library or program that does this, hardly can I be the first to have that thought.

Robert Siverd

unread,
May 27, 2013, 5:53:56 AM5/27/13
to astro...@googlegroups.com

What's a good FITS viewer? I have a kinda crappy one (fv).

I like DS9, which is available for most platforms. It does a lot and has solid documentation.
http://hea-www.harvard.edu/RD/ds9/site/Home.html

-Rob

Dustin Lang

unread,
May 28, 2013, 9:35:54 AM5/28/13
to astro...@googlegroups.com

One comment about the SIP polynomials: you can turn them off with "solve-field --no-tweak" or maybe "solve-field --tweak-order 1", possibly resulting in poorer alignment (depending on how much distortion your images have), but making the WCS headers easier for various packages to interpret.

I also posted a reply in the "Drizzle" thread about the "wcs-resample" program in Astrometry.net, that may do what you want.

cheers,
dustin

Philip Bergen

unread,
May 29, 2013, 1:06:05 AM5/29/13
to astro...@googlegroups.com
Aloha Dustin,
Thanks! I'll look into that. I have many parts to work out, so the fact that I can align pictures at all is pretty amazing right now. :)

// Phil
Reply all
Reply to author
Forward
0 new messages