Advertisement / Annons: 
Tutorial:

Content:
Note: 
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: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: Matrix: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: T_{1} T_{2} T_{3} T_{4} = T_{tot}
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, x_{ij} and y_{ij}, 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 T_{tot} 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, x_{1}, y_{1} and x'_{1}, y'_{1} and so on should align on each other after the transformation (align) process. That is what matrix T_{tot} take care of. 
Warping: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' = Sum_{i} Sum_{j} a_{ij}x^{i}y^{j} Remember from school: x^{0} = 1 and x^{1} = x, always! If we limit it to a second degree polynomial it will look like this:
x' = a_{0} + a_{1}x + a_{2}y + a_{3}x^{2} + a_{4}y^{2} + a_{5}xy 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.

