(1, 0): 2, (0, 1): 3, (1, 1): 4, (1, -1): 5, (-1, 1): 6, (-1, -1): 7 } dir_dict2 = [[-1, 0], [0, -1], [1, 0], [0, 1]] dir_dict3 = [[-1, -1], [1, -1], [1, 1], [-1, 1]] # Object: assign cost-to-go to elements of the centerline # Method: breadth-first search # Set goal location skel = np.asarray(skel_3d(mazeData), dtype=int) skel[42, 178:185] = 1 start = [42, 184] # plt.imshow(skel + mazeData) plt.show() # Initialize centerline cost-to-go map costMap = np.copy(mazeData) pgrad = np.copy(mazeData) flowMapCol = 0 * mazeData flowMapRow = 0 * mazeData goal = [158, 18] #[158, 18] #[22, 56]
(1, -1): 5, (-1, 1): 6, (-1, -1): 7 } dir_dict2 = [[-1, 0], [0, -1], [1, 0], [0, 1]] dir_dict3 = [[-1, -1], [1, -1], [1, 1], [-1, 1]] # Object: assign cost-to-go to elements of the centerline # Method: breadth-first search import skimage raw_img = plt.imread(os.path.join(ROOT_PATH, mapfile + '.png')) bw = raw_img[:, :, 0] bw[bw < 1] = 0 skel = np.asarray(skel_3d(bw), dtype=np.int16) / 255 ## For Map0522 # start = [77, 453] ## For Map 523 # start = [183, 450] ## For map 0524 start = [213, 570] skel_Frontier = [start] cost = 100 pgradSkel = np.copy(skel) pgradSkel[skel_Frontier[-1][0], skel_Frontier[-1][1]] = cost