[英]How do I get downscale and get B&W pixel values from an image in Python?
[英]How do I get pixel information from a FITs image in Python?
我試圖在 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
最后一行給了我一個 output ,我假設它是像素的值,但是我得到一個大約 109 的值,而不是大約 0 的值,因為圖像中的黑色或非常接近它的像素。
我嘗試將 (0,0) 作為圖片的左上角和左下角,但都沒有得到 0。
我也嘗試使用 PIL 和 skimage 來獲取像素的值,但是當我嘗試打開圖像時,兩者都會導致“找不到適合文件的加載器”錯誤。
關於如何獲得像素值的任何建議?
(0,0) 可能是左下角的 position 和 image_data 中的 x 和 y 軸反轉(image_data[y][x])。 請參閱:https://docs.astropy.org/en/stable/io/fits/usage/image.html
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.