-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0c8e8ae
commit ebcb5cd
Showing
4 changed files
with
78 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) |
Binary file not shown.
Binary file not shown.