Exemplo n.º 1
0
# CORRELATION_RADIUS
source_kernel = np.ones((5, 5))
background_kernel = np.ones((100, 10))

kbe = KernelBackgroundEstimator(images=images,
                                source_kernel=source_kernel,
                                background_kernel=background_kernel,
                                significance_threshold=SIGNIFICANCE_THRESHOLD,
                                mask_dilation_radius=MASK_DILATION_RADIUS)

kbe.run(n_iterations=3)

# In[ ]:

kbe.run_iteration()

# In[ ]:

kbe._data[1].print_info()

# ## Plot results
#
# TODO

# In[ ]:

n_iterations = 5

#plt.clf()
plt.figure(figsize=(10, 10))
kbe = KernelBackgroundEstimator(
    images=images,
    source_kernel=source_kernel,
    background_kernel=background_kernel,
    significance_threshold=SIGNIFICANCE_THRESHOLD,
    mask_dilation_radius=MASK_DILATION_RADIUS,
)

n_iterations = 4

# *** RUN & PLOT ***
plt.figure(figsize=(8, 4))

for iteration in range(n_iterations):
    kbe.run_iteration()
    mask_hdu = kbe.mask_image_hdu
    mask = mask_hdu.data[:, 1400:2000]

    plt.subplot(n_iterations, 2, 2 * iteration + 1)
    background_hdu = kbe.background_image_hdu
    data = background_hdu.data[:, 1400:2000]
    plt.imshow(data, vmin=0, vmax=1)
    plt.contour(mask, levels=[0], linewidths=2, colors='white')
    plt.axis('off')
    plt.title('Background Estimation, Iteration {0}'.format(iteration),
              fontsize='small')

    plt.subplot(n_iterations, 2, 2 * iteration + 2)
    significance_hdu = kbe.significance_image_hdu
    data = significance_hdu.data[:, 1400:2000]