This is the simple Dijkstra methode to find the shortes path on a shell. Put in the start p and target point q and the Matrix in doube format Matrix then you get the path. The first component of the point is the column and the second the row. For the output path one gets the used path, prev are the previous visited pixels, unvis are the unvisited pixels, and distance the weigted distance of the pixels.
Create scripts with code, output, and formatted text in a single executable document.