This project implements an image-based graph detection system using Dijkstra's algorithm to find the shortest path between two nodes in a weighted, undirected graph drawn on an image.
The system:
- Detects nodes (black circles with labels) and edge weights (red numbers),
- Extracts valid connections using image processing and OCR,
- Applies Dijkstra’s algorithm to compute the shortest path,
- Draws the resulting path directly onto the original image.
All logic, explanation, and usage instructions are contained in the notebook file (dijkstra_image_pathfinding.ipynb
).
- OpenCV (
cv2
) – image processing, shape detection, drawing - pytesseract – OCR to detect node labels and edge weights
- NumPy – numerical operations, distance calculations
- math – geometric computations
- Google Colab patch (
cv2_imshow
) – used to display images in Google Colab
Note: If you're using Jupyter Notebook locally, replace
cv2_imshow()
withmatplotlib.pyplot.imshow()
orcv2.imshow()
as needed, sincecv2_imshow()
is specific to Google Colab.
- Upload or create an image with a graph following the drawing rules described in the notebook.
- Open the notebook in Google Colab (recommended) or Jupyter Notebook.
- Run all cells — the script will:
- Detect graph structure,
- Apply Dijkstra’s algorithm,
- Output the original image with the shortest path highlighted.
This project is open-source and licensed under the MIT License.