Beispiel #1
0
			plt.ylabel(' MSE ')
			s = 0
			for curv_type in curv_types:
				err= list()
				for sigma in Sigma:
					cc = 'hex_quad_k1_' + str(Ks[i][0]) + '_k2_' + str(Ks[i][1]) + '_' + str(nstep) + '_noise_' + str(
						int(sigma * 1000))
					# os.chdir(r"/hpc/meca/users/souani.a/curvature/Compute_curvatures/Noise")
					# os.mkdir(cc )
					# os.chdir(r"/hpc/meca/users/souani.a/curvature/Compute_curvatures/Noise/"+cc)
					# sio.write_mesh(mesh, cc+'.gii')
					list_exampels.append(cc)
					mesh_file = 'hex_quad_k1_' + str(Ks[i][0]) + '_k2_' + str(Ks[i][1]) + '_' + str(nstep) + '.gii'
					os.chdir("/hpc/meca/users/souani.a/curvature/Compute_curvatures/Curvatures/0Noise")
					mesh = sio.load_mesh(mesh_file)
					xx = sps.quadric_curv_mean(Ks[i][0], Ks[i][1])(mesh.vertices[:, 0], mesh.vertices[:, 1])
					xx_m = np.zeros((nstep ** 2, 1))
					texture_file = cc + '_curv_mean_' + curv_type + '.gii'
					# mesh.apply_transform(mesh.principal_inertia_transform)
					os.chdir(
						"/hpc/meca/users/souani.a/curvature/Compute_curvatures/Curvatures/Noise/" + cc)
					tex = sio.load_texture(texture_file)
					err.append(mean_squared_error(xx, tex.darray))
				
				plt.plot( Sigma,err, color=couleur[s] , marker= 'o', label=str(curv_types[s]))
				print("Done for "+ cc[:-5]+ ' for '+ curv_type)
				# plt.text(Sigma[0], err[0], curv_types[s], fontsize=9)
				s += 1
			# plt.show()
			os.chdir(r"/hpc/meca/users/souani.a/curvature/Compute_curvatures/Curvatures/Figures/Mean_squarred_error_function_of_noise")
			plt.savefig("MSE function of noise for " + cc)
Beispiel #2
0
				for curv_type in curv_types:
					mesh_file = 'hex_quad_k1_' + str(Ks[i][0]) + '_k2_' + str(Ks[i][1]) + '_' + str(nstep) + '.gii'
					texture_file = cc + '_curv_mean_' + curv_type + '.gii'
					os.chdir("/hpc/meca/users/souani.a/curvature/Compute_curvatures/Quadrics")
					mesh = sio.load_mesh(mesh_file)
					# mesh.apply_transform(mesh.principal_inertia_transform)
					
					os.chdir(
						"/hpc/meca/users/souani.a/curvature/Compute_curvatures/Noise/" + cc)
					tex = sio.load_texture(texture_file)
					
					# splt.pyglet_plot(mesh, tex.darray, plot_colormap=True)
					# splt.pyglet_plot(mesh, tex.darray, 'hot', plot_colormap=True)
					# print(tex.darray)
					data.append(tex.darray)
				xx = sps.quadric_curv_mean(Ks[i][0], Ks[i][1])(mesh.vertices[:, 0], mesh.vertices[:, 1])
				xx = np.reshape(xx, (1, nstep ** 2))
				data = np.array(data)
				data_m = np.zeros((6, nstep ** 2))
				data_m[:5, :] = data[:, :, 0]
				data_m[5, :] = xx
				
				
				data_m = np.array(data_m)
				embedding = MDS(n_components=2)
				data_t = embedding.fit_transform(data_m[:, :])
				# print(data_t)
				fig = plt.figure()
				ax = fig.add_subplot(111)
				fig.suptitle(cc)
				plt.xlabel('First component')
Beispiel #3
0
    mesh = trimesh.Trimesh(faces=faces, vertices=coords, process=False)
    
    # Show the quadric
    # mesh.show()

    # Estimate curvatures by Rusinkiewicz method
    PrincipalCurvatures, PrincipalDir1, PrincipalDir2 = CC.GetCurvaturesAndDerivatives(mesh)
    gaussian_curv = PrincipalCurvatures[0, :] * PrincipalCurvatures[1, :]
    mean_curv = 0.5 * (PrincipalCurvatures[0, :] + PrincipalCurvatures[1, :])

    # Calculate mean error between real and estimated curvatures

    #Mean curvature
    
    mesh_coords = mesh.vertices
    curv_mean_real = gqs.quadric_curv_mean(Ks[0][0], Ks[0][1])(mesh_coords[:, 0], mesh_coords[:, 1])
    print("Error = ", 20*np.log(np.mean(np.abs(mean_curv / curv_mean_real))))

    #Gauss curvature
    
    curv_gauss_real = gqs.quadric_curv_gauss(Ks[0][0], Ks[0][1])(mesh_coords[:, 0], mesh_coords[:, 1])
    print("Error = ", 20*np.log(np.mean(np.abs(gaussian_curv / curv_gauss_real))))
   
   
    # Plot mean curvature
    
    vect_col_map = \
        trimesh.visual.color.interpolate(mean_curv, color_map='jet')
    
    if mean_curv.shape[0] == mesh.vertices.shape[0]:
        mesh.visual.vertex_colors = vect_col_map
                # Generate the quadric
                # X, Y, faces, Zs = gqs.generate_quadric([ks], nstep=list_nbr_steps[i], ax=list_ax_ay[i][0ay=list_ax_ay[i][1])
                # Z = Zs[0]
                # coords = np.array([X, Y, Z]).transpose()
                # mesh = trimesh.Trimesh(faces=faces, vertices=coords, process=False)
                # mesh.show()
                # print("mesh surface = ", mesh.area, "\n surface needed = ", list_surfaces[i])

                os.chdir(
                    r"/hpc/meca/users/souani.a/curvature/Compute_curvatures/Curvatures/0Noise"
                )
                cc = 'hex_quad_k1_' + str(ks[0]) + '_k2_' + str(
                    ks[1]) + '_' + str(list_nbr_steps[i])
                mesh = sio.load_mesh(cc + '.gii')
                data = list()
                xx = gqs.quadric_curv_mean(ks[0], ks[1])(mesh.vertices[:, 0],
                                                         mesh.vertices[:, 1])
                print("-------------------------------" + cc + '_noise_' +
                      str(int(sigma * 1000)))
                for curv_type in curv_types:
                    print(curv_type)
                    texture_file = cc + '_noise_' + str(int(
                        sigma * 1000)) + '_curv_mean_' + curv_type + '.gii'

                    # mesh.apply_transform(mesh.principal_inertia_transform)

                    os.chdir(
                        "/hpc/meca/users/souani.a/curvature/Compute_curvatures/Curvatures/Noise/"
                        + cc + '_noise_' + str(int(sigma * 1000)))
                    tex = sio.load_texture(texture_file)
                    data.append(tex.darray)
                data = np.array(data)