Ejemplo n.º 1
0
def demo():
    image = normalise(camera().astype("f"))
    blurred_image, psf_kernel = add_microscope_blur_2d(image)
    noisy_blurred_image = add_poisson_gaussian_noise(
        blurred_image, alpha=0.001, sigma=0.1, sap=0.01, quant_bits=10
    )

    deconvolved_image = cg_restoration(
        noisy_blurred_image,
        kernel=psf_kernel,
        num_iterations=200,
        lmbda=4.5e-3,
        mu=1e-10,
    )

    deconvolved_image = deconvolved_image.clip(0, 1)

    import napari

    with napari.gui_qt():
        viewer = napari.Viewer()
        viewer.add_image(image, name="image")
        viewer.add_image(blurred_image, name="blurred")
        viewer.add_image(noisy_blurred_image, name="noisy_blurred_image")
        viewer.add_image(deconvolved_image, name="deconvolved_image")
Ejemplo n.º 2
0
def original_demo():
    Lambda = 1e-7  # weight of TV regularization
    mu = 1e-10  # parameter of TV smoothing
    n_it = 500  # number of iterations

    image = normalise(camera().astype("f"))

    kern = gaussian1D(2.6)
    K = ConvolutionOperator(kern)
    P = lambda x: K * x
    PT = lambda x: K.T() * x

    blurred_image = add_noise(P(image), intensity=None, variance=0.00)

    en, deconvolved_image = conjugate_gradient_TV(P, PT, blurred_image, Lambda,
                                                  mu, n_it)

    import matplotlib.pyplot as plt

    plt.figure()
    plt.plot(en)
    plt.show()

    import napari

    with napari.gui_qt():
        viewer = napari.Viewer()
        viewer.add_image(image, name="image")
        viewer.add_image(blurred_image, name="blurred")
        viewer.add_image(deconvolved_image, name="deconvolved_image")
Ejemplo n.º 3
0
def original_demo():
    beta = 1e-7  # weight of TV regularization
    n_it = 500  # number of iterations

    # Init.
    # ------
    image = normalise(camera().astype('f'))

    kern = gaussian1D(2.6)
    K = ConvolutionOperator(kern)
    P = lambda x: K * x
    PT = lambda x: K.T() * x

    # Run
    blurred_image = add_noise(P(image), intensity=None, variance=0.00)
    L = power_method(P, PT, blurred_image, n_it=200)
    print("||K|| = %f" % L)
    en, deconvolved_image = chambolle_pock(P, PT, blurred_image, beta, L, n_it)

    import matplotlib.pyplot as plt
    plt.figure()
    plt.plot(en)
    plt.show()

    import napari

    with napari.gui_qt():
        viewer = napari.Viewer()
        viewer.add_image(image, name='image')
        viewer.add_image(blurred_image, name='blurred')
        viewer.add_image(deconvolved_image, name='deconvolved_image')
Ejemplo n.º 4
0
def demo():
    image = normalise(camera().astype('f'))
    blurred_image, psf_kernel = add_microscope_blur_2d(image)
    noisy_blurred_image = add_poisson_gaussian_noise(blurred_image,
                                                     alpha=0.001,
                                                     sigma=0.1,
                                                     sap=0.01,
                                                     quant_bits=10)

    deconvolved_image = cp_restoration(noisy_blurred_image,
                                       kernel=psf_kernel,
                                       num_iterations=200,
                                       beta=2e-3)

    deconvolved_image = deconvolved_image.clip(0, 1)

    import napari
    with napari.gui_qt():
        viewer = napari.Viewer()
        viewer.add_image(image, name='image')
        viewer.add_image(blurred_image, name='blurred')
        viewer.add_image(noisy_blurred_image, name='noisy_blurred_image')
        viewer.add_image(deconvolved_image, name='deconvolved_image')