I am trying to find the intensities of given pixels in a FITs image in Python. The image is black and white so I'm only looking for the values of the pixels.
The code I'm using is:
import matplotlib.pyplot as plt
import astropy
from astropy.io import fits
from astropy.utils.data import get_pkg_data_filename
image_file = get_pkg_data_filename('jet.fits')
image_data = fits.getdata(image_file,ext=0)
image = fits.open('jet.fits')
image.info()
image_data[400][500] #the 400 being the x coordinate of the pixel and the #500 being the y coordinate of the pixel
The last line gives me an output which I am assuming is the value of the pixel, however I get a value of around 109 instead of a value around 0 as the pixel in the image in black or very close to it.
I have tried taking (0,0) as both the upper left corner of the picture and the lower left corner and neither get 0.
I have also tried using PIL and skimage to get the value of the pixel but both result in an "cannot find loader for this fits file" error when I try and open the image.
Any suggestions on how I can get the pixel value?
(0,0) might be the position of the lower left corner and the x and y axis in image_data are reversed (image_data[y][x]). See: https://docs.astropy.org/en/stable/io/fits/usage/image.html
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.