Esempio n. 1
0
c_init = [
    b_init[0] + r_c * np.cos(theta_b_init + theta_c_init),
    b_init[1] + r_c * np.sin(theta_b_init + theta_c_init)
]

a = [0., 0.]
b = [
    a_init[0] + r_b * np.cos(theta_b_init),
    a_init[1] + r_b * np.sin(theta_b_init)
]
c = [
    b[0] + r_c * np.cos(theta_b_init + theta_c_init),
    b[1] + r_c * np.sin(theta_b_init + theta_c_init)
]

template_init = fun_gen.generate_image_2articulations(space, a, b, c,
                                                      0.1 * width)
template = template_init.copy()
#template = 10*space.element(scipy.ndimage.filters.gaussian_filter(template_init.asarray(), 10))
template.show('template', clim=[0, 1])
plt.plot(a[0], a[1], 'xr')
plt.plot(b[0], b[1], 'xr')
plt.plot(c[0], c[1], 'xr')

proj_data = forward_op(template)

# Add white Gaussion noise onto the noiseless data
noise = 0.25 * odl.phantom.noise.white_noise(forward_op.range)

# Create the noisy projection data
noise_proj_data = proj_data + noise

theta_b_init = 0.5*np.pi
theta_c_init = 0.1*np.pi

a_init =[0., 0.]
b_init = [a_init[0] + r_b*np.cos(theta_b_init), a_init[1] + r_b*np.sin(theta_b_init)]
c_init = [b_init[0] + r_c*np.cos(theta_b_init + theta_c_init), b_init[1] + r_c*np.sin(theta_b_init + theta_c_init)]

a = [0., 0.]
b = [a_init[0] + r_b*np.cos(theta_b_init), a_init[1] + r_b*np.sin(theta_b_init)]
c = [b[0] + r_c*np.cos(theta_b_init+theta_c_init), b[1] + r_c*np.sin(theta_b_init+theta_c_init)]



template_init = fun_gen.generate_image_2articulations(space, a, b, c, width)
template = space.element(scipy.ndimage.filters.gaussian_filter(template_init.asarray(),1))
template.show()
plt.plot(a[0], a[1],'xr')
plt.plot(b[0], b[1],'xr')
plt.plot(c[0], c[1],'xr')


proj_data = forward_op(template)

# Add white Gaussion noise onto the noiseless data
noise =0.25 * odl.phantom.noise.white_noise(forward_op.range)

# Create the noisy projection data
noise_proj_data = proj_data + noise
nb_ab = int((ab_norm + 0.2*width) / sigma) +1
nb_bc = int((bc_norm  + 0.2*width) / sigma) +1


Cont = rd.uniform(-2, 2, [nbdata, 2])

sblur = 5

for i in range(nbdata):
    a = param.T[i][0:2]
    b = param.T[i][2:4]
    c = param.T[i][4:6]
    truth_temp = generate_truthblurred_from_param(param.T[i], Cont[i,0], Cont[i,1], sblur).copy()
    #truth_temp = space.tangent_bundle.element(truth_temp)

    image_list.append(fun_gen.generate_image_2articulations(space, a, b, c, width))

    vector_fields_list.append(truth_temp.copy())
    points, vectors = cmp.compute_pointsvectors_2articulations_bis_nb(a, b, c, width, sigma, n_orth, nb_ab, nb_bc)
    points_list.append(points.copy())
    vectors_list.append(vectors.copy())
#

if False:
    a = param.T[i][0:2]
    b = param.T[i][2:4]
    c = param.T[i][4:6]
    v_temp0 = fun_gen.generate_vectorfield_2articulations_0(space, a, b, c, width).copy()
    v_temp1 = fun_gen.generate_vectorfield_2articulations_1(space, a, b, c, width).copy()
    v_temp1.show()
    plt.plot(param.T[i][::2], param.T[i][1::2])
Esempio n. 4
0
vectors_list = []
cov_mat_list = []
param_list = []
A_inner_prod_list = []
image_list = []
nbdatamax = 5
for i in range(nbdatamax):
    structured_list.append(np.loadtxt(name + 'structured' + str(i)))
    unstructured_list.append(np.loadtxt(name + 'unstructured' + str(i)))
    vectors_i = structured_list[i][dim:2 * dim]
    points_list.append(np.loadtxt(name + 'points' + str(i)))
    vectors_list.append(np.loadtxt(name + 'vectors' + str(i)))
    param_tmp = np.loadtxt(name + 'param' + str(i))
    param_list.append(param_tmp)
    image_temp = fun_gen.generate_image_2articulations(
        space, param_tmp[0:2], param_tmp[2:4],
        param_tmp[2:4] + 0.85 * (param_tmp[4:6] - param_tmp[2:4]),
        0.5 * width).copy()
    image_list.append(
        space.element(scipy.ndimage.filters.gaussian_filter(image_temp, 10)))
    cov_mat_list.append(
        struct.make_covariance_matrix(points_list[i], kernel_np))
    A_inner_prod_list.append(
        np.dot(cov_mat_list[i], np.dot(vectors_i.T, vectors_list[i])).T)
#

param_list = np.array(param_list).T

nb_points = len(points_list[0][0])
nb_vectors = len(vectors_list[0][0])

points = space.points()
nb_bc = 8

Cont = rd.uniform(-2, 2, [nbdata, 2])

sblur = 5

for i in range(nbdata):
    a = param.T[i][0:2]
    b = param.T[i][2:4]
    c = param.T[i][4:6]
    truth_temp = generate_truthblurred_from_param(param.T[i], Cont[i, 0],
                                                  Cont[i, 1], sblur).copy()
    #truth_temp = space.tangent_bundle.element(truth_temp)

    image_list.append(
        fun_gen.generate_image_2articulations(space, a, b, c, width))

    vector_fields_list.append(truth_temp.copy())
    points, vectors = cmp.compute_pointsvectors_2articulations_thin(
        a, b, c, nb_ab, nb_bc)
    points_list.append(points.copy())
    vectors_list.append(vectors.copy())
#

if False:
    a = param.T[i][0:2]
    b = param.T[i][2:4]
    c = param.T[i][4:6]
    v_temp0 = fun_gen.generate_vectorfield_2articulations_0(
        space, a, b, c, width).copy()
    v_temp1 = fun_gen.generate_vectorfield_2articulations_1(