| 1 |
from frames import Frames |
| 2 |
import pyfits |
| 3 |
from numpy import moveaxis |
| 4 |
|
| 5 |
import cv2 |
| 6 |
from cv2 import cvtColor, COLOR_RGB2BGR, COLOR_BGR2RGB |
| 7 |
|
| 8 |
def astropy_fits(filename_in, filename_out): |
| 9 |
frame = cvtColor(Frames.read_image(filename_in), COLOR_RGB2BGR) |
| 10 |
|
| 11 |
cv2.imshow('Example - Show image in window', frame) |
| 12 |
|
| 13 |
cv2.waitKey(0) |
| 14 |
cv2.destroyAllWindows() |
| 15 |
|
| 16 |
Frames.save_image(filename_out, cvtColor(frame, COLOR_BGR2RGB), color=True) |
| 17 |
|
| 18 |
def pyfits_fits(filename_in, filename_out): |
| 19 |
frame = cvtColor(pyfits.getdata(filename_in), COLOR_RGB2BGR) |
| 20 |
|
| 21 |
cv2.imshow('Example - Show image in window', frame) |
| 22 |
|
| 23 |
cv2.waitKey(0) |
| 24 |
cv2.destroyAllWindows() |
| 25 |
|
| 26 |
if len(frame.shape) == 3: |
| 27 |
frame = moveaxis(frame, -1, 0) |
| 28 |
hdu = pyfits.PrimaryHDU(frame) |
| 29 |
header = "PlanetarySystemStacker" |
| 30 |
hdu.header['CREATOR'] = header |
| 31 |
hdu.writeto(filename_out, overwrite=True) |
| 32 |
|
| 33 |
|
| 34 |
filename = 'frame.fits' |
| 35 |
|
| 36 |
pyfits_fits(filename, "frame_out.fits") |