Giter Club home page Giter Club logo

fits_to_img's Introduction

Fits To Image in Python

  • This program converts .fits file to .jpg file. (Or you can convert fits file to png or bmp in little modification)

Installation

  • Command git clone https://github.com/psds075/fitstoimg.git.
  • Make new folder 'data' and 'image' in current directory, and copy .fits files to data folder. (mkdir data, mkdir image)
  • Command python fitstoimg.py.
  • In linux environment, you should revise directory character '\' -> '/'.
  • It is tested on Windows 10, Linux Ubuntu 16.04.
$ git clone https://github.com/psds075/fitstoimg.git
$ mkdir data
$ mkdir image
$ python3 fitstoimg.py

Code (fitstoimg.py)

import os
import numpy as np
from PIL import Image
from astropy.io import fits
import img_scale

dir_path = os.getcwd()
for filename in os.listdir(dir_path+"\\data"):
    if filename.endswith(".fits"):
        image_data = fits.getdata("data\\"+filename)
        if len(image_data.shape) == 2:
            sum_image = image_data
        else:
            sum_image = image_data[0] - image_data[0]
            for single_image_data in image_data:
                sum_image += single_image_data  

        sum_image = img_scale.sqrt(sum_image, scale_min=0, scale_max=np.amax(image_data))
        sum_image = sum_image * 200
        im = Image.fromarray(sum_image)
        if im.mode != 'RGB':
            im = im.convert('RGB')
    
        im.save(dir_path+"\\image\\"+filename+".jpg")
        im.close()

Contact

fits_to_img's People

Contributors

psds075 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.