【问题标题】:Photutils Source Detection doesnt work for small pic, works for large, why?Photutils 源检测不适用于小图片,适用于大图片,为什么?
【发布时间】:2018-08-27 10:39:39
【问题描述】:

我正在尝试检测图片上的星星/天文物体。 这是我可以做得很好的图片,如下所述:

按照given on this site 的建议,我有这个代码:

from astropy.stats import sigma_clipped_stats
from photutils.datasets import make_100gaussians_image
from photutils import find_peaks
import matplotlib.pyplot as plt
from astropy.visualization import simple_norm
from astropy.visualization.mpl_normalize import ImageNormalize
from photutils import CircularAperture
data = make_100gaussians_image()
mean, median, std = sigma_clipped_stats(data, sigma=3.0)
threshold = median + (5. * std)
tbl = find_peaks(data, threshold, box_size=11)
positions = (tbl['x_peak'], tbl['y_peak'])
apertures = CircularAperture(positions, r=5.)
norm = simple_norm(data, 'sqrt', percent=99.9)
plt.imshow(data, cmap='Greys_r', origin='lower', norm=norm)
apertures.plot(color='#0547f9', lw=1.5)
plt.xlim(0, data.shape[1]-1)
plt.ylim(0, data.shape[0]-1)

它工作正常,这是输出:

如果我将第 10 行修改为 threshold = median + (30. * std),那么我会得到一个标记为更少星的输出,正如预期的那样。这是输出:

现在,我想将它用于这个文件:

为此,我运行此代码,源代码是从 FITS 文件加载的:

import lightkurve
tpf=lightkurve.targetpixelfile.KeplerTargetPixelFile('ktwo201103700-c102_lpd-targ.fits')
from astropy.stats import sigma_clipped_stats
from photutils.datasets import make_100gaussians_image
from photutils import find_peaks
import matplotlib.pyplot as plt
from astropy.visualization import simple_norm
from astropy.visualization.mpl_normalize import ImageNormalize
from photutils import CircularAperture
#data = make_100gaussians_image()
data = tpf.flux[100]
mean, median, std = sigma_clipped_stats(data, sigma=3.0)
threshold = median + (0.1 * std)
tbl = find_peaks(data, threshold, box_size=11)
#tbl['peak_value'].info.format = '%.8g'  # for consistent table output
#print(tbl[:10])    # print only the first 10 peaks
positions = (tbl['x_peak'], tbl['y_peak'])
apertures = CircularAperture(positions, r=1.)
norm = simple_norm(data, 'sqrt', percent=99.9)
plt.imshow(data, cmap='Greys_r', origin='lower', norm=norm)
apertures.plot(color='#0547f9', lw=1.5)
plt.xlim(0, data.shape[1]-1)
plt.ylim(0, data.shape[0]-1)

输出如下。无论我在第 13 行中给出的阈值多么小,它只能找到一颗星,而不是两颗,正如我们所希望的那样。

为什么会这样,我该如何解决?

【问题讨论】:

    标签: python image-processing physics astronomy astropy


    【解决方案1】:

    使用 box_size=4 我有这个结果:

    jupyter notebook 中运行您的脚本之前,我必须安装这些模块:

    pip3 install jupyter lightkurve photutils
    

    – 并使用此命令也可以查看图像结果:

    plt.interactive(True)
    %matplotlib
    

    【讨论】:

    • 来自这里:photutils.readthedocs.io/en/stable/background.html:“Photutils 提供了 Background2D 类来估计天文图像中的 2D 背景和背景噪声。Background2D 需要估计背景的框的大小 (box_size) . 选择框大小需要用户注意。框大小通常应大于图像中源的典型大小,但要小到足以封装任何背景变化。不在关于源检测的页面上,但我仍然认为这可以解释问题。
    猜你喜欢
    • 2012-08-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-04-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多