Origin of FITS files in ImageJ

If I open a FITS file with python and inspect the value at coordinate (0,0) like so


from astropy.io import fits
import sys
import numpy
from astropy.utils.data import download_file
numpy.set_printoptions(threshold=sys.maxsize)
image_file = download_file('http://data.astropy.org/tutorials/FITS-images/HorseHead.fits', cache=True )
data = fits.getdata(image_file)
print(data[0][0])

It prints 7201. However when I open this file in ImageJ it says that the (0,0) coordinate is 5796 while the lower left coordinate is ~7201. I think this may be because FITS files are laid out with the 0th row on the bottom and built upwards from there.

Thus the image is “flipped” from what I expected in python (astropy). I suppose this is fine but a little confusing. However I think its actually a bug/issue because ImageJ actually labels (0,0) as the top left while displaying the last row. I think it should label it (0,810 - the height) if thats what it wants to do because its a FITS file.

Is this a bug/issue? Or am I misunderstanding.

This appears to be an issue with FITS_Reader in ImageJ 1.x, as the same image opened with Bio-Formats Importer correctly shows 7201 at position (0,0).

See the screenshot (left image: opened with ImageJ’s FITS_Reader, right image: opened with #bio-formats):

Note though that the bio-formats version is lacking the image information in the subtitle.

2 Likes

Is there a way to set that Bio format importer as the default importer as opposed to FITS_Reader? I got Bio Formats Importer working and can see it labeled as I expect like you show, but its a pain to have to go through the entire Import process each time. I want to just double click on a file in the explorer or drag and drop as usual

The FITS Reader in the latest ImageJ daily build (1.52p21) does not flip images vertically so you should now see the expected pixel values.

1 Like