sampled_X_on_sphere = put_on_sphere(sampled_X) # print(sampled_X_on_sphere[0]) # Find centroid of data # final_p = sphere_centroid_finder_vecs(sampled_X_on_sphere, sampled_X.shape[1], 0.05, 0.01) # print(final_p) final_p_img = final_p.reshape(m, n) plt.imshow(final_p_img, cmap=plt.get_cmap('gray')) plt.show() h = choose_h_gaussian(sampled_X_on_sphere, final_p, 85) # needs to be very high! radius = choose_h_binary(sampled_X_on_sphere, final_p, 40) upper, curve, lower = principal_boundary(sampled_X_on_sphere, sampled_X.shape[1], 0.02, h, radius, \ start_point=final_p, kernel_type="gaussian", max_iter=40) print("upper") for j in range(5): for i in range(9): plt.subplot(330 + 1 + i) plt.imshow(upper[i + 9 * j].reshape(m, n), cmap=plt.get_cmap('gray')) plt.show() print("curve") for j in range(5): for i in range(9): plt.subplot(330 + 1 + i) plt.imshow(curve[i + 9 * j].reshape(m, n), cmap=plt.get_cmap('gray'))
# Sample from train_X # train_samples = np.random.choice(train_X.shape[0], size=SAMPLES) sampled_X = train_X[train_samples] sampled_X_on_sphere = put_on_sphere(sampled_X) # print(sampled_X_on_sphere[0]) # Find centroid of data # final_p = sphere_centroid_finder_vecs(sampled_X_on_sphere, sampled_X.shape[1], 0.05, 0.01, max_iter=100) # print(final_p) final_p_img = final_p.reshape(m, n) plt.imshow(final_p_img, cmap=plt.get_cmap('gray')) plt.show() # Find principal flow and display first 27 images of flow obtained # h = choose_h_binary(sampled_X_on_sphere, final_p, 10) # needs to be very high! radius = choose_h_binary(sampled_X_on_sphere, final_p, 30) curve = principal_flow(sampled_X_on_sphere, sampled_X.shape[1], 0.01, h, \ start_point=final_p, kernel_type="binary", max_iter=30) # idea: upsample images print("curve") for j in range(6): for i in range(9): plt.subplot(330 + 1 + i) plt.imshow(curve[i + 9*j].reshape(m, n), cmap=plt.get_cmap('gray')) plt.show() np.save(os.path.abspath(os.curdir)+'\\data\\cartoon_grayscale_30_flow.npy', curve) '''