# Compute reference mesh quantities of interest (array, mean, standard deviation) f_mesh, f_mean, f_stddev = analysis.ref_mesh_qoi(ref_surf, uv_vals, ref_sub_coeff, ref_sub_image.shape) # Test synthetically deformed control points synth_coords = np.zeros((len(coords), 2)) for i in range(len(synth_coords)): synth_coords[i, :] = np.matmul(F, coords[i, :]) + np.array([dx, dy]) # Compute synthetic control point displacements synth_coords_disp = synth_coords - coords # Compute znssd between synthetic and ref coordinates synth_znssd = analysis.mesh_znssd(f_mesh, f_mean, f_stddev, def_sub_image.shape, ref_surf, uv_vals, def_sub_coeff, synth_coords_disp) # Print the synthetic info to stdout data_out = 'Using image data from ' + data print(data_out) print('Synthetic ZNSSD: {}'.format(synth_znssd)) print('Synthetic Coordinate Displacements') print(synth_coords_disp) print('Deformation gradient at center of ROI from synthetic control points') print(visualize.def_grad(ref_surf, 0.5, 0.5, synth_coords_disp)) # Wrap minimization arguments into a tuple arg_tup = (f_mesh, f_mean, f_stddev, def_sub_image.shape, ref_surf, uv_vals, def_sub_coeff)
y = coords[:, 1] fig, ax = plt.subplots(figsize=(10, 20)) ax.imshow(ref_image, cmap='gray') ax.plot(x, y, 'o', color='red') plt.savefig(name + 'mesh.png') # Test synthetically deformed control points synth_coords = np.zeros((len(coords), 2)) for i in range(len(synth_coords)): synth_coords[i, :] = np.matmul(F, coords[i, :]) + np.array([dx, dy]) # Compute synthetic control point displacements synth_coords_disp = synth_coords - coords # Compute znssd between synthetic and ref coordinates synth_znssd = analysis.mesh_znssd(roi, ref_image.shape, def_image.shape, ref_surf, uv_vals, ref_coeff, def_coeff, synth_coords_disp) # Print the synthetic info to stdout print('Synthetic ZNSSD: {}'.format(synth_znssd)) print('Synthetic Coordinate Displacements') print(synth_coords_disp) # Visualize synthetic displacement results # Set up new surface disp_surf = bs.Surface() disp_surf.degree_u = 3 disp_surf.degree_v = 3 disp_surf.set_ctrlpts(synth_coords_disp.tolist(), num_ctrlpts, num_ctrlpts) disp_surf.knotvector_u = gutil.generate_knot_vector(disp_surf.degree_u, num_ctrlpts)