我试图在Python中的FITs图像中找到给定像素的强度。图像是黑白的,所以我只是在寻找像素的值。
我使用的代码是:
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
最后一行给出了一个输出,假设是像素的值,但是我得到的值大约是109,而不是0左右的值,它是图像中黑色或非常接近它的像素。
我试着把( 0 ,0)作为图片的左上角和左下角,但都没有得到0。
我也尝试过使用PIL和skimage来获取像素的值,但当我尝试打开图像时,两者都会导致“无法找到加载程序用于此fits文件”的错误。
关于我如何得到像素值有什么建议吗?
发布于 2022-01-04 08:25:00
(0,0)可能是左下角的位置,image_data中的x和y轴颠倒(image_datay)。请参阅:https://docs.astropy.org/en/stable/io/fits/usage/image.html
https://stackoverflow.com/questions/63262372
复制