以令人费解的方式从图像中获取数据?

问题描述 投票:0回答:1

因此,我导入了FITS文件,并使用astropy和matplotlib显示了图像。该图像有一些亮点,但我不知道如何在图像上突出显示特定的关注亮点并获得亮度的平均值。谁能帮忙?

python matplotlib astropy
1个回答
0
投票

示例:

from astropy.io import fits
import numpy as np
import matplotlib.pyplot as plt

## Read
hdul = fits.open('yourfile.fits')
image = hdul[0].data
Ny, Nx = image.shape

## Mean (careful if the unit is MJy/sr)
avg = np.nanmean(image)
print('Image mean = ', avg)

## Plot (mark bright spots)
xl = []
yl = []
for x in range(Nx):
    for y in range(Ny):
        if image[y,x]>avg:
            xl.append(x)
            yl.append(y)
plt.imshow(image)
plt.scatter(xl, yl, c='r', marker='o')
plt.show()
© www.soinside.com 2019 - 2024. All rights reserved.