def mat_comp():
    tik_alpha = 1
    tv_alpha = 0.1

    # Creating measurement data
    data = r.radon(phantom[n], theta)

    A = r.radon_matrix(n_ang, n)
    At = np.transpose(A)

    # Adding noise
    noise_level = 0.05
    noisy_data = data + noise_level * np.random.randn(data.shape[0],
                                                      data.shape[1])

    # Compute the reconstruction
    rec_tik = tik_primal_dual_mat_alt(A, At, noisy_data, (n, n), tik_alpha)
    rec_ls = LS_primal_dual_mat(A, At, noisy_data, (n, n))
    rec_tv = TV_primal_dual_mat(A, At, noisy_data, (n, n), tv_alpha)

    pylab.gray()
    pylab.figure(0)
    pylab.title("Least-Squares reconstruction")
    pylab.imshow(rec_ls)
    pylab.figure(1)
    pylab.title("Tikhonov reconstruction")
    pylab.imshow(rec_tik)
    pylab.figure(2)
    pylab.title("Total Variation reconstruction")
    pylab.imshow(rec_tv)

    pylab.show()
def comp():
    tik_alpha = 1

    # Creating measurement data
    data = r.radon(phantom[n], theta)

    # Adding noise
    noise_level = 0.05
    noisy_data = data + noise_level * np.random.randn(data.shape[0],
                                                      data.shape[1])

    # Compute the reconstruction
    rec_tik = tik_primal_dual_alt(noisy_data, (n, n), tik_alpha)
    rec_ls = LS_primal_dual(noisy_data, (n, n))

    pylab.gray()
    pylab.figure(0)
    pylab.title("Least-Squares reconstruction")
    pylab.imshow(rec_ls)
    pylab.figure(1)
    pylab.title("Tikhonov reconstruction")
    pylab.imshow(rec_tik)

    pylab.show()
예제 #3
0
        if show_prog:
            if i % 50 == 0:
                gap = 1/2*np.linalg.norm(A.dot(ft)-meas_v, 2)**2 + 1/2 * \
                    np.linalg.norm(pk, 2)**2 + np.dot(pk, meas_v)
                pylab.figure(2)
                pylab.title("Iteration {} | Dual gap: {:.2f}".format(i, gap))
                pylab.gray()
                pylab.imshow(np.reshape(ft, f_shape))
                pylab.pause(0.1)

    return np.reshape(ft, f_shape)


if __name__ == "__main__":
    # Creating measurement data
    data = r.radon(phantom[n], theta)

    #A = r.radon_matrix(theta, n)
    #At = np.transpose(A)

    # Adding noise
    noise_level = 0.05
    noisy_data = data + noise_level * np.random.randn(data.shape[0],
                                                      data.shape[1])

    # Compute the reconstruction
    rec = LS_primal_dual(noisy_data, (n, n), True)
    #rec = LS_primal_dual_mat(A, At, noisy_data, (n,n), True)

    pylab.gray()
    pylab.figure(0)
예제 #4
0
def Af(f):
    # Define the forward projection with given number of angles

    global theta
    return r.radon(f, theta)
def A(f):
    global theta
    return r.radon(f, theta)