Author Topic: Dynamic Alignment - Why not fully automatic?  (Read 8683 times)

Offline fneyer

  • Newcomer
  • Posts: 31
Dynamic Alignment - Why not fully automatic?
« on: 2012 January 29 07:43:55 »
I'm relatively new to PixInsight - although I used it already several times. My question now is about the dynamic alignment tool. I think it has a great potential - better than the automatic star alignment. Specially when dealing with images that have a considerable amount of distortion, the star alignment tool fails. However, since the dynamic alginment tool is a semi-automatic script, you still have to manually select reference stars which is very time consuming if you have many images.
Is it not possible to use the automatic star detection routine of the star alignment tool in the dynamic alignment tool? If this would be available, pixinsight would be THE alignment software to chose (appart from all the other great advantages of course..  ;) ). So far, only Registar can automatically register images of various scales and local distortions although the software is a bit out-dated (data format, speed, ...). I hope pixinsight can do this, or is it state not reached yet?

Thanks!
Fabian

ruediger

  • Guest
Re: Dynamic Alignment - Why not fully automatic?
« Reply #1 on: 2012 February 07 01:27:28 »
Hi Fabian,

from my experience todays PixInsight's capabilities of tolerating local distortions in the star alignment tools need some improvements. For example, I tried to make a mosaic from two 24mm shots with about 30% overlap with the Dynamic Alignment Tool. After placing some stars in both shots manually, every next star I picked in the reference frame snapped perfectly to its companion in the second frame, but regardless of how many stars I selected, the tool was not able to register the two frames without obvious errors. An automatic star detection wouldn't have helped in this case.
I also tried to register a stack of 15 x 50mm shot against an artifical starfield (created with the StarGenerator tool) with the fully automatic Star Alignment Tool. Even though the registration process didn't report any errors, the final stack showed some doubled stars towards the corners. Have you ever tried to register against an artifical starfield? Maybe it's working perfectly and fully automatic with your files.

From this post from Juan http://pixinsight.com/forum/index.php?topic=3689.msg25897#msg25897 improvements to the StarAlignment process are mentioned, so maybe we just have to wait a little bit.

Regards
 Rüdiger

Offline Juan Conejero

  • PTeam Member
  • PixInsight Jedi Grand Master
  • ********
  • Posts: 7111
    • http://pixinsight.com/
Re: Dynamic Alignment - Why not fully automatic?
« Reply #2 on: 2012 February 07 02:43:46 »
Quote
Dynamic Alignment - Why not fully automatic?

Because that is extremely difficult, if not impossible! Notice that the application you have mentioned is not able to perform the same tasks as our DynamicAlignment tool, which is much more flexible.

Let me elaborate a bit on this topic for a better perspective. A feature-based image registration process works by finding points of interest (also known as background control points or alignment features) on two images, which are used as alignment references. Then it has to solve one of the most difficult problems of image processing: the point correspondence problem. This consists of determining pairs of corresponding points of interest on both images. Once a sufficiently large set of corresponding points have been found, building a geometrical transformation to register the images is relatively straightforward.

To solve the point correspondence problem we need a robust descriptor for each point of interest. Robust descriptors allow us to characterize a given point of interest with minimal uncertainty. To achieve this goal a descriptor must be invariant to some key geometrical transformations: translation, rotation and scale change as a minimum. The pairs of corresponding points can thus be matched by some kind of classification procedure, and a robust model fitting algorithm such as RANSAC can be applied to remove outliers (false pair matches). In the case of daylight images, each point of interest has a significant neighborhood, from which a robust descriptor can be built using several image analysis techniques. For example, local gradient and texture information can be used to characterize the surrounding area of each point. SIFT and SURF are the two best examples of this class of techniques. SIFT is patented and subject to royalties so we cannot implement it (we cannot pay for it, and on the other hand I am one of those stupid persons radically against patented algorithms). SURF is free and we are currently starting to work on an implementation of it for PixInsight. It will be the basis of a panorama generation tool (no time schedule yet).

However, in the case of stars used as alignment features, we have an interesting paradox:

- Stars are nearly ideal image registration features because they are essentially point-like structures and can be detected very accurately and easily.

- A star is probably the worst possible image registration feature because it lacks a significant neighborhood. A star is basically a point-like structure surrounded by a constant level (the local background). The only significant neighbors of a star are other stars.

In the StarAlignment tool I have implemented an elegant and robust algorithm, where triangle similarity is used to build a robust descriptor for each star. You have complete information and references on the reference documentation for StarAlignment. As described in the documentation, however, the problem with triangle similarity is that it is intolerant of distortion: it can only be used to define essentially an affine transformation. In my implementation I have pushed triangle similarity to tolerate some global distortion (with a careful triangle generation strategy and a versatile RANSAC routine), but that isn't sufficient to support huge differential distortions such as those involved in mosaics of widefield images.

All the problem reduces to finding more flexible robust descriptors for stars. Note that the SIFT and SURF algorithms, which are the gold standards in panorama generation---maybe there is something more advanced, but I am not aware of it---, allow for a full projective transformation (a homography) instead of an affine transformation. I we were able to find something similar with stars (in both efficiency and robustness) we would take a big step forward. I have some ideas and have made some initial experiments that look promising. Definitely this is one of our main R+D topics for this year.

That said, DynamicAlignment is a completely different beast. It can be used to register two images subject to *any* kind of arbitrary distortion. The only limit is that your eye+brain system must be able to detect at least three star matches between both images. Don't expect this functionality implemented as a fully automatic tool such as StarAlignment. You can expect however a new version of DynamicAlignment with many improvements and a mosaic generation mode. We'll start working on it soon.
Juan Conejero
PixInsight Development Team
http://pixinsight.com/

Offline Juan Conejero

  • PTeam Member
  • PixInsight Jedi Grand Master
  • ********
  • Posts: 7111
    • http://pixinsight.com/
Re: Dynamic Alignment - Why not fully automatic?
« Reply #3 on: 2012 February 07 03:03:29 »
Hi Rüdiger,

Quote
I tried to make a mosaic from two 24mm shots with about 30% overlap with the Dynamic Alignment Tool. After placing some stars in both shots manually, every next star I picked in the reference frame snapped perfectly to its companion in the second frame, but regardless of how many stars I selected, the tool was not able to register the two frames without obvious errors.

Theoretically that's impossible :) If that happens, then either (1) you made one or more mistakes (i.e., you selected one or more wrong stars in the target image), or (2) the geometrical transformation required to align both images is so complex that you need more and/or better distributed alignment stars.

DynamicAlignment uses 2-D surface splines (aka thin plates) as a registration model. This means that DA can register two images subject to virtually any arbitrary geometrical transformation. This also means that DA can, provided that the spatial distribution of alignment points is sufficiently dense and uniform, adapt the registration model to any kind of local (i.e., small-scale) distortions. By the way, DBE uses a similar interpolation device.

Could you upload both images somewhere so I can try to register them?
Juan Conejero
PixInsight Development Team
http://pixinsight.com/

Offline georg.viehoever

  • PTeam Member
  • PixInsight Jedi Master
  • ******
  • Posts: 2132
Re: Dynamic Alignment - Why not fully automatic?
« Reply #4 on: 2012 February 07 04:07:06 »
Hi Juan,

... If that happens, then either (1) you made one or more mistakes (i.e., you selected one or more wrong stars in the target image),...

such issues would be easier to diagnose if DynamicAlignment would have the ability to overlay a grid that is transformed with the image. See post http://pixinsight.com/forum/index.php?topic=2160.msg23945#msg23945 for a scripted way of doing it.

Georg
Georg (6 inch Newton, unmodified Canon EOS40D+80D, unguided EQ5 mount)

Offline Juan Conejero

  • PTeam Member
  • PixInsight Jedi Grand Master
  • ********
  • Posts: 7111
    • http://pixinsight.com/
Re: Dynamic Alignment - Why not fully automatic?
« Reply #5 on: 2012 February 07 06:09:27 »
Hi Georg,

Indeed, those grids will be optional control images generated in the next version of DA. I appreciate this clever idea ;)
Juan Conejero
PixInsight Development Team
http://pixinsight.com/

Offline georg.viehoever

  • PTeam Member
  • PixInsight Jedi Master
  • ******
  • Posts: 2132
Re: Dynamic Alignment - Why not fully automatic?
« Reply #6 on: 2012 February 07 09:34:24 »
Ruediger,

I am pretty sure that stars that are further away from the group you already matched will not snap perfectly. This is because of lens distortion and/or the fact that we are trying to map a sphere to a plane.

In my experiments, DynamicAlignment worked quite well provided I distributed the alignment stars such that they cover the whole overlapping image region, and in particular the corners of the region. Creating these matches admittedly is very tedious work, especially since the snapping no longer helps (it can be actually quite misleading).

Georg
Georg (6 inch Newton, unmodified Canon EOS40D+80D, unguided EQ5 mount)

ruediger

  • Guest
Re: Dynamic Alignment - Why not fully automatic?
« Reply #7 on: 2012 February 07 09:58:32 »
Hi Rüdiger,

Quote
I tried to make a mosaic from two 24mm shots with about 30% overlap with the Dynamic Alignment Tool. After placing some stars in both shots manually, every next star I picked in the reference frame snapped perfectly to its companion in the second frame, but regardless of how many stars I selected, the tool was not able to register the two frames without obvious errors.

Theoretically that's impossible :) If that happens, then either (1) you made one or more mistakes (i.e., you selected one or more wrong stars in the target image), or (2) the geometrical transformation required to align both images is so complex that you need more and/or better distributed alignment stars.

Could you upload both images somewhere so I can try to register them?
Hi Juan,

I tried again with the following two pictures and 30 placed reference points. The result (averaged of left milky way part with registered picture) still shows obvious errors. When do I know, that I have selected enough stars? If I remember correctly, first time I tried the alignment I gave up with 60 or even more reference points and still didn't get a good result.

Here are 2048 pixel width jpegs to play with:
http://www.flickr.com/photos/urlaubsknipser/6323206571/sizes/o/in/set-72157627414413822/
http://www.flickr.com/photos/urlaubsknipser/6032871028/sizes/o/in/set-72157627414413822/

Regards,
 Rüdiger

ruediger

  • Guest
Re: Dynamic Alignment - Why not fully automatic?
« Reply #8 on: 2012 February 07 10:23:17 »
I am pretty sure that stars that are further away from the group you already matched will not snap perfectly. This is because of lens distortion and/or the fact that we are trying to map a sphere to a plane.
Hi Georg,
I'm currently playing with the two pictures from my last post. You are right, the correct snapping only takes place in the close vicinity of other reference points. Once you have placed the reference points on the obvious brighter stars of the very dense milky way starfield, it's getting progressively harder to verify the correct placement of the reference points. I tried the process some months ago and probably made some placement errors. But now, even with 50+ verified reference points, the pictures still don't match.
Regards,
 Rüdiger

Offline georg.viehoever

  • PTeam Member
  • PixInsight Jedi Master
  • ******
  • Posts: 2132
Re: Dynamic Alignment - Why not fully automatic?
« Reply #9 on: 2012 February 07 10:33:40 »
With my 18 mm lens, I used around 350 alignment points. The results where ok - except for a few stars where I got the alignment points wrong. Took me 3 iterations until the result was decent.  The thin plate model apparrently is not very good in extrapolating the kind of distortions that these lenses produces.

I experimented with autopano http://www.kolor.com/panorama-software-autopano-pro.html, which produced decent results with fewer alignment points. Unfortunately,  panorama software does not work well with stars.

Georg
Georg (6 inch Newton, unmodified Canon EOS40D+80D, unguided EQ5 mount)

ruediger

  • Guest
Re: Dynamic Alignment - Why not fully automatic?
« Reply #10 on: 2012 February 07 12:07:10 »
With my 18 mm lens, I used around 350 alignment points.
[...]
I experimented with autopano http://www.kolor.com/panorama-software-autopano-pro.html, which produced decent results with fewer alignment points.
I use Autopano Pro quite a long time now and it's no problem (at least not with the latest 2.6 version) to make panoramas from widefield star field shots like the two given examples. However, my original intention was to perform the registration with the linear FITS files and develop them as a whole to achieve a uniform look.

If you say you needed 350 alignment points (= every star? :D ) it looks like I was too impatient and gave up early.

Rüdiger

Offline fneyer

  • Newcomer
  • Posts: 31
Re: Dynamic Alignment - Why not fully automatic?
« Reply #11 on: 2012 February 07 13:26:04 »
Hi Rüdiger, Juan, and Georg,

Thanks for your answers!
Juan, thanks for the clarification about the different functionality between the DA and SA tools. So the problem is to find a robust and more in-depth solution based on the principle of the SA tool. I may have some ideas how to improve the StarAlignment tool or to extend its functionality towards automatism. I'm thinking of an iterative method were you first use the triangle similarity of StarAlignment for a first transformation model (this can be an affine or a projective transformation). In the second iteration, you use this knowledge to locally improve your model. The more iteration you make, the better local distortions can be corrected in principle. In order to garantee smooth transitions between the local parameter estimations, a vector model space could be created (i.e. you convert the transformation parameters into vector components), median filtered and interpolated using a Gaussian function. Maybe you have similar ideas?

There are a few papers were you can read about dividing an image into subregions to locally correct for distortion is here:
- Image Registration by local approximation methods - by Ardeshir Goshtasby (1988)
- An adaptive method for image registraion - by Jan Flusser (1992)
- ...

It would simply great if this could be implemented!

Fabian




Offline georg.viehoever

  • PTeam Member
  • PixInsight Jedi Master
  • ******
  • Posts: 2132
Re: Dynamic Alignment - Why not fully automatic?
« Reply #12 on: 2012 February 07 13:58:06 »
Juan,
[...However, in the case of stars used as alignment features, we have an interesting paradox:
- Stars are nearly ideal image registration features because they are essentially point-like structures and can be detected very accurately and easily.
- A star is probably the worst possible image registration feature because it lacks a significant neighborhood. A star is basically a point-like structure surrounded by a constant level (the local background). The only significant neighbors of a star are other stars.
...
There is also aspects that should make automatic alignment of star images easier than the typical panorama construction task:
- you dont have changing point of views/perspective, limiting the set of necessary transformations
- there is a set of typical distortions caused by wide field lenses (e.g. fish eye, pin cushion, barrel, ...)
- there is a typical set of transformations that are useful for projecting from a sphere to a plane
- and there is (typically) not too much movement in the foreground of the images.

In reports from people doing large mosaic, I usually read that they are using some kind of plate solvers (e.g. Astrometry.net) to get the WCS coordinates of their images, and then something like Swarp (http://www.astromatic.net/2010/09/04/swarp-2-19-1-release) to project them to the plane. Some approach like this, and especially the reduced sets of transformations, should make the task easier. It is still a formidable one....

Georg
Georg (6 inch Newton, unmodified Canon EOS40D+80D, unguided EQ5 mount)

ruediger

  • Guest
Re: Dynamic Alignment - Why not fully automatic?
« Reply #13 on: 2012 February 07 23:10:15 »
In reports from people doing large mosaic, I usually read that they are using some kind of plate solvers (e.g. Astrometry.net) to get the WCS coordinates of their images, and then something like Swarp (http://www.astromatic.net/2010/09/04/swarp-2-19-1-release) to project them to the plane.
Isn't this the principle of THELI's approach to the registration process? In other forums, I see more and more people using THELI for data reduction and PixInsight for everything else.

Rüdiger