2

I would like to read FITS file image data and display it like standard image using java and nom.tam.fits library. Right now I manage to read data into two dimensional array. In my case returned 4 dimensional array with size [1][1][1024][1024]. In this array last two dimensions is image data.

Fits fitsFile = new Fits(path);
ImageHDU imageHDU = (ImageHDU) fitsFile.readHDU();
StandardImageTiler tiler = imageHDU.getTiler();
float[][][][] tmp = (float[][][][]) tiler.getCompleteImage();
float[][] imgData = tmp[0][0];

This array contains float numbers like:

8.9243695E-5
7.172857E-5
5.233031E-5
3.137777E-5
-6.0740327E-5
3.137777E-5
-3.7215374E-5
-6.0740327E-5
9.2222035E-6

Do you have any idea how I can convert it to standard image (.img, .jpg, .png...)

There is example of FITS file converting to image in python http://www.astropy.org/astropy-tutorials/FITS-images.html

Iguananaut
  • 21,810
  • 5
  • 50
  • 63
  • I don't know off the top of my head, but a FITS image is just a 2D array of pixel values, so once you have the array any other Java-based solution for writing an array of values to an image will work. The fact that they were originally stored in a FITS file is not necessarily special. Though depending on how you do this you may need to scale the float values to some integer pixel values. – Iguananaut Mar 07 '18 at 13:22

0 Answers0