Astrofriend's homepage
Share: Twitter Reddit Facebook Gmail Gmail Email
Search Astrofriend's homepage:

Valid CSS!

All pages shall now have been validated

Info Cookies (Kakor) / GDPR


Advertisement /

Twitter @AstrofriendLars

Follow Astrofriend

Travel News

Advertisement / Annons:

AstroImageJ Align and Drizzle


  1. Introduction matrix
  2. Align points test
  3. Size of output matrix
  4. Inverse matrix
  5. Determinant
  6. Matlab and Octave
  7. Parallel Super-Resolution Plug in
  8. Parallel Super-Resolution Plug in, test 2
  9. Temporary solution with new workflow

I take no responsibility or liability for what are written here, you use the information at your own risk!

1, Introduction:

This is an attempt from me to create a macro to AstroImageJ to align and stack sub images with a Drizzle function.

Expect me to edit and correct a lot here in the beginning. But follow it if you find it interesting to see how I develop the functions and see if I reach the goal, a working Drizzle function!


Drizzle is a way to increase the resolution of under sampled images, i.e. when you have big size pixels on a high resolution telescope.

More information about Drizzle:


First we, especially me have to dig deeper in the mathematical word about matrices and transformation. Uses of matrices in the calculations can make it a lot easier to do it.

Here you find deeper information about matrices:

The base tranformation matrices:

Unit matrix
1 0 0
0 1 0
0 0 1

Unit matrix, does nothing to the image.

Translation matrix
1 0 X
0 1 Y
0 0 1

Translation matrix, shifts the image in x and y axis.

Scale matrix
W 0 0
0 H 0
0 0 1

Scale the x (W=width) and y (H=height) axis, many times W could be set equal to H, symmetry.

Rotation matrix
Cos(v) Sin(v) 0
-Sin(v) Cos(v) 0
0 0 1

Rotation matrix, rotate the image by angle v.

Altogether these matrices correspond to: T1 T2 T3 T4 = Ttot

Overall matrix, Ttot
W*Cos(v) W*Sin(v) X
-H*Sin(v) H*Cos(v) Y
0 0 1

Translation, Scale and rotation matrices (functions) put together in one matrix.

How to use T:

X' = T X, T transform the coordinates of X to X'.

X consist of the pixel coordinates, xij and yij, i=row and j=column. X' is the new coordinates. First we must find out what T is. To that we use our reference star as we get when we align our sub images. To X we put in our reference stars coordinates from our sub images. X' is the reference stars coordinates reference image (one of the sub images normally). One T matrix for each of your sub images will transform them to the reference image coordinates.

The Ttot will do an Affine transformation, all the three transformations above, to that we need three reference stars. Note: It will not correct optical distortion.

X coordinates (three reference star in one sub image)
x1 x2 x3
y1 y2 y3
1 1 1

X' coordinates (three reference star in reference image)
x'1 x'2 x'3
y'1 y'2 y'3
1 1 1

Each column are the coordinates of the center of a reference star, x1, y1 and x'1, y'1 and so on should align on each other after the transformation (align) process. That is what matrix Ttot take care of.


My first plan was to limit it my translation to an Affine translation, I don't want it be to complex to solve. But after some talk in the Swedish forum Astronet about optical distortion I feel I must also have correction of distortion from the beginning.

This is a more complex translation and it often is called warping. With that I need a higher degree of polynomial in the transfer function.

Here is a very useful explanation about what I aim for:

Higher degree polynomial:

The general form of a high degree polynomial looks like this:

x' = Sumi Sumj aijxiyj
y' = Sumi Sumj bijxiyj

Remember from school: x0 = 1 and x1 = x, always!

If we limit it to a second degree polynomial it will look like this:

x' = a0 + a1x + a2y + a3x2 + a4y2 + a5xy
y' = b0 + b1x + b2y + b3x2 + b4y2 + b5xy

Or in matrix form:

X' = Zt

X' is a two row column vector.

X' vector

Z is a matrix of two rows and 12 columns.

Z matrix
1 x y x2 y2 xy 0 0 0 0 0 0
0 0 0 0 0 0 1 x y x2 y2 xy

t is a vector of 12 rows and one column.

t vector

Twelve unknown parameters that we have to solve. Each reference star give us two equations, x' and y'.

Now I have some understanding and overview of what I have to do.

There is also a couple of Warp plugins to ImageJ that I maybe could built my own function around, however, they are more specialized to work with microscope images.

Go Back to content

Go Back
Next part: II, Test of align points

Advertisement / Annons: