diff --git a/live_wire.py b/live_wire.py index a0b2694ddfd25abcc4654514ab760118ccfaf6d3..46eb2dd0a8ba0e438d04b7c5a1055c1a4e4bba46 100644 --- a/live_wire.py +++ b/live_wire.py @@ -83,13 +83,21 @@ def backtrack_pixels_on_image(img_color, path_coords, bgr_color=(0, 0, 255)): img_color[row, col] = bgr_color return img_color +def export_path(path_coords, path_name): + """ + Export the path to a np array. + """ + np.save(path_name, path_coords) + return None + + #### Main Script #### def main(): # Define input parameters - image_path = 'bipes_slice.png' + image_path = 'agamodon_slice.png' image_type = 'gray' # 'gray' or 'color' downscale_factor = 100 # % of original size - points_path = 'bipesPoints.npy' + points_path = 'agamodonPoints.npy' # Load image image = load_image(image_path, image_type) @@ -128,11 +136,15 @@ def main(): # If you want to mark it in red, do (0,0,255) because OpenCV uses BGR format. color_img = backtrack_pixels_on_image(color_img, path_rc, bgr_color=(0, 0, 255)) + + # Export path + export_path(path_rc, 'agamodonPath.npy') + # Display results plt.figure(figsize=(20, 8)) plt.subplot(1, 2, 1) - plt.title("Canny Edges") - plt.imshow(canny_img, cmap='gray') + plt.title("Cost image") + plt.imshow(cost_image, cmap='gray') plt.subplot(1, 2, 2) plt.title("Path from Seed to Target")