A package for aligning and comparing astronomical images
Project description
StarsAlign - A package developed for aligning and comparing high density astronomical images with extreme precision
StarsAlign is a tool for aligning and comparing astronomical images using the Scale-Invariant Feature Transform (SIFT) algorithm and FLANN based matcher.
It contains functions such as fast_align()
and fast_diff()
that aligns and compute the difference of two single channel images.
The package also contains align()
and diff()
functions for extreme precision, but they may require more resources.
Another useful tool of this package is the normalize()
function, wich normalize the image by subtracting the mean from all pixels of the image and then dividing by the standard deviation. This can be useful in cases where the images have different brightness levels.
Examples of this package usage can be found inside the folder: https://github.com/nagonzalezf/starsalign/tree/main/examples
Reference Image | Science Image | Raw Difference Image |
---|---|---|
Reference Image | Aligned Science Image | Aligned Difference Image |
---|---|---|
Important
Functions fast_align()
and fast_diff()
were specifically designed to work with images that have a high amount of information, such as 4096x2048 pixels, with float32 data type, and a range of values between -40000 and 40000.
It is recommended to use the align()
and diff()
functions on lower resolution or lower density images, but it may result in prolonged waiting times for bigger images.
Installation
Using pip:
pip install starsalign
Using setup.py
file from root directory
python setup.py install
Examples
Getting the aligned science image using fast_align()
function (faster method)
>>> import starsalign as sa
>>> aligned_image = sa.fast_align(ref_image, science_image)
Getting the aligned difference image with a more precise alignment using diff()
function (slower but more accurate)
>>> import starsalign as sa
>>> aligned_difference_image = sa.diff(ref_image, science_image)
Supported input formats
By default the package is intended to be use over float 32 single channel images of wide range, but it can also process other formats such as uint8 images or even binary images.
The fast_align()
and fast_diff()
functions will only support single channel images.
If you want to process multi channel images you have two options:
-
You can use the
align()
anddiff()
functions, these will automatically get rid of the multi channels and perform the calculations over temporary buffer single channel images to finally process and extract the original multi channel images as output. -
You can get rid of the extra channels yourself performing some pre-processing tasks such as opencv
cvtColor()
functions for color space conversions or similar methods and then process the images using thefast_align()
andfast_diff()
functions.
Difference Image Analysis (DIA) application examples
The main idea behind this technique is to subtract two images of the same portion of the sky, removing all photometrically stable stars, but tipically this images are not aligned by default.
Example 1 - fast_align()
& fast_diff()
functions
We are working over two wide-range float32 images of the NGC6569 globular cluster in the constellation Sagittarius. These images were captured using the Dark Energy Camera (DECam) instrument of the Victor M. Blanco 4-meter Telescope at the Cerro Tololo Inter-American Observatory (CTIO) in the Chilean Andes. They were pre-processed using the data reduction pipelines developed by the Rubin Observatory (LSST pipelines).
Reference Image | Science Image | Raw Difference Image |
---|---|---|
The reference and science images are not aligned, so the raw difference results are incorrect.
We process the image using fast_align()
and fast_diff()
functions (faster method):
>>> import starsalign as sa
>>> aligned_image = sa.fast_align(ref_image, science_image)
>>> aligned_difference_image = sa.fast_diff(ref_image, science_image)
And we get the desired difference result:
Reference Image | Aligned Science Image | Aligned Difference Image |
---|---|---|
Note:
This results were obtained using the lsst.dirac.dev resources (CPU, RAM) and they were calculated in about 8 seconds. If we perform the proccesing under the same conditions using align()
and diff()
functions, then it takes about 20 minutes to complete and we get a slightly more accurate x and y displacement value calculations.
The source float32 images used for this examples can be found at: https://github.com/nagonzalezf/starsalign/blob/main/examples/ref_image.npy https://github.com/nagonzalezf/starsalign/blob/main/examples/science_image.npy
Documentation
Documentation is under construction, in the meantime you can check:
SIFT algorithm docs at: https://docs.opencv.org/4.x/da/df5/tutorial_py_sift_intro.html
FLANN feature matcher docs at: https://docs.opencv.org/4.x/d5/d6f/tutorial_feature_flann_matcher.html
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file starsalign-1.1.0.tar.gz
.
File metadata
- Download URL: starsalign-1.1.0.tar.gz
- Upload date:
- Size: 7.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.8
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7625b4aa182925582664b31c74b5284d8182b04b4a2869dd51ba760474e32b11 |
|
MD5 | c2ec065e3b190c09f89ec58f07cdfe64 |
|
BLAKE2b-256 | 7ea7b6c8635c2a1c35a703b32123419158212c8fe007aec8cb539fb61dfcd3e9 |
File details
Details for the file starsalign-1.1.0-py3-none-any.whl
.
File metadata
- Download URL: starsalign-1.1.0-py3-none-any.whl
- Upload date:
- Size: 6.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.8
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9c3221c18c8ec4e5fa5e92a3887b427bb7912796513773131157db16a7430cd6 |
|
MD5 | 46d11fb2fb43a7816e299ab4d666e0e1 |
|
BLAKE2b-256 | 50e954cc310c8bfe3d72b8d765ca005276ab388e79fb692ebcbf5ee81ad33fb0 |