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, does nothing to the image.
Translation matrix, shifts the image in x and y axis.
Scale the x (W=width) and y (H=height) axis, many times W could be set equal to H, symmetry.
Rotation matrix, rotate the image by angle v.
Altogether these matrices correspond to: T1 T2 T3 T4 = Ttot
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.
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
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
Or in matrix form:
X' = Zt
X' is a two row column vector.
Z is a matrix of two rows and 12 columns.
t is a vector of 12 rows and one column.
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.