diff --git a/examples/example_1.py b/examples/example_1.py new file mode 100644 index 0000000..c3b956b --- /dev/null +++ b/examples/example_1.py @@ -0,0 +1,39 @@ +""" +This example shows how to use the STARSALIGN package to align two single channel astronomical images. + +It loads two images 'ref_image.npy' and 'science_image.npy', then it uses the functions 'align()' +and 'diff()' from the STARSALIGN package to get the aligned and difference images. + +Finally, it saves all the images in .png format using opencv. + +https://github.com/nagonzalezf/starsalign/ +""" +# Imports +import os +import cv2 as cv +import numpy as np +import starsalign as stal + +# Load images +ref_image = np.load('ref_image.npy') +science_image = np.load('science_image.npy') + +# Get the raw difference image +raw_diff_image = ref_image - science_image + +# Use the starsalign align() function to get the aligned image +aligned_image = stal.align(ref_image, science_image) + +# Use the starsalign diff() function to get the difference image +diff_image = stal.diff(ref_image, science_image) + +# Create outputs folder +if not os.path.exists("example_1_outputs"): + os.makedirs("example_1_outputs") + +# Write stored variables as simple .png images to visualize in explorer +cv.imwrite('example_1_outputs/001_ref_image.png', ref_image) +cv.imwrite('example_1_outputs/002_science_image.png', science_image) +cv.imwrite('example_1_outputs/003_raw_diff_image.png', raw_diff_image) +cv.imwrite('example_1_outputs/004_aligned_image.png', aligned_image) +cv.imwrite('example_1_outputs/005_diff_image.png', diff_image) \ No newline at end of file diff --git a/examples/example_2.py b/examples/example_2.py new file mode 100644 index 0000000..1e93ab2 --- /dev/null +++ b/examples/example_2.py @@ -0,0 +1,39 @@ +""" +This example shows how to use the STARSALIGN package to align two single channel astronomical images. + +It loads two images 'ref_image.npy' and 'science_image.npy', then it uses the functions 'ultra_align()' +and 'ultra_diff()' from the STARSALIGN package to get the aligned and difference images. + +Finally, it saves all the images in .png format using opencv. + +https://github.com/nagonzalezf/starsalign/ +""" +# Imports +import os +import cv2 as cv +import numpy as np +import starsalign as stal + +# Load images and extract small 500x500 patches for each image +ref_image = np.load('ref_image.npy')[1800:2300, 250:750] +science_image = np.load('science_image.npy')[1800:2300, 250:750] + +# Get the raw difference image +raw_diff_image = ref_image - science_image + +# Use the starsalign ultra_align() function to get the aligned image +aligned_image = stal.ultra_align(ref_image, science_image) + +# Use the starsalign ultra_diff() function to get the difference image +diff_image = stal.ultra_diff(ref_image, science_image) + +# Create outputs folder +if not os.path.exists("example_2_outputs"): + os.makedirs("example_2_outputs") + +# Write stored variables as simple .png images to visualize in explorer +cv.imwrite('example_2_outputs/001_ref_image.png', ref_image) +cv.imwrite('example_2_outputs/002_science_image.png', science_image) +cv.imwrite('example_2_outputs/003_raw_diff_image.png', raw_diff_image) +cv.imwrite('example_2_outputs/004_aligned_image.png', aligned_image) +cv.imwrite('example_2_outputs/005_diff_image.png', diff_image) \ No newline at end of file diff --git a/examples/ref_image.npy b/examples/ref_image.npy new file mode 100644 index 0000000..c2a23fb Binary files /dev/null and b/examples/ref_image.npy differ diff --git a/examples/science_image.npy b/examples/science_image.npy new file mode 100644 index 0000000..fa0ecee Binary files /dev/null and b/examples/science_image.npy differ