From 1153c47ce0614795a49344bca73640406635da5b Mon Sep 17 00:00:00 2001 From: Antonio De Lucreziis Date: Thu, 1 Aug 2024 17:23:14 +0200 Subject: [PATCH] updated algorithm file --- ALGORITHM.md | 40 ++++++++++++++++++++++++++++++---------- 1 file changed, 30 insertions(+), 10 deletions(-) diff --git a/ALGORITHM.md b/ALGORITHM.md index 0d245ac..8340786 100644 --- a/ALGORITHM.md +++ b/ALGORITHM.md @@ -1,42 +1,62 @@ # Algorithm Explanation -- Step 001: Load the image +1. **Load**. + + First we load the image step 1 - image -- Step 002: Normalize the image +2. **Normalization**. + + The we use a median blur to extract the background and then remove it from the image. Then we normalize the image. step 2 - normalized -- Step 003: Erode the image +3. **Erosion**. + + Then we draw some white rectangles over all the markers to hide them as they would occlude the maze. Then we erode the image to remove noise and make the maze lines thicker. step 3 - eroded -- Step 004: Threshold the image +4. **Threshold**. + + Now we binarize the image using a threshold (a good number I found is about ~200) step 4 - threshold -- Step 005: Dilate the image +5. **Dilate**. + + Then we dilate the image to make the lines even thicker. step 5 - dilated -- Step 006: Crop the image +6. **Cropping**. + + We crop the image using markers 1 and 2 to get the maze region. step 6 - cropped -- Step 007: Show the maze with start and end points +7. **Maze**. + + We draw the maze with the start (red) and end (green) points in the new coordinates. step 7 - maze -- Step 008: Create the maze bitmap +8. **Bitmap**. + + We create a bitmap of the maze to use it in the A* algorithm. The bitmap is a 2D array where 0 is a free cell and 1 is a wall. We use networkx to run the A* algorithm. step 8 - maze bitmap -- Step 009: Find the maze path +9. **Path**. + + We draw the path found by the A* algorithm on the maze bitmap. step 9 - maze path -- Step 010: Show the solution +10. **Solution**. + + Finally we transform the path back to the original image coordinates and draw it on the image. step 10 - solution