title: How to find shortest path in skeletonized maze image?
body: <p>I am working on maze solving using <em>Image Processing</em> and <em>NetworkX</em> search algroithm and need to find the shortest connecting path between two points on those lines. </p>
  
  <pre><code>#Solving Maze Using Image Processing and NetWorkx search
  
  
  
      #Open Maze image
      img = cv2.imread("C:/Users/Dell/HandMadeMaze1.jpg")
      kernel = np.ones((1,1),np.uint8)
  
      #Convert to GrayScaledImage
      grayscaled = cv2.cvtColor(img,cv2.COLOR_BGR2GRAY)
  
      #BınaryThreshold + OtsuThreshold + BinaryThreshold
      retval, threshold = cv2.threshold(grayscaled, 10, 255, cv2.THRESH_BINARY_INV+cv2.THRESH_OTSU)
      retval, threshold2 = cv2.threshold(threshold, 10, 255, cv2.THRESH_BINARY_INV)
      threshold2[threshold2 == 255] = 1
  
      #Skeletonize the Thresholded Image
      skel = skeletonize(threshold2)
  
      #Build Graph from skeleton
      graph = sknw.build_sknw(skel, multi=False)
      G = nx.Graph(graph)
      plt.imshow(img, cmap='gray')
  
      #Draw Edges by 'pts'
      for (s,e) in graph.edges():
          ps = graph[s][e]['pts']
          plt.plot(ps[:,1], ps[:,0], 'red')
  
      #Draw Node by 'o'   
      node, nodes = graph.node, graph.nodes()
      ps = np.array([node[i]['o'] for i in nodes])
      plt.plot(ps[:,1], ps[:,0], 'g.')
      plt.title('Skeletonize')
      plt.savefig('Overlay_Maze.jpg')
      plt.show()
  
      G = nx.path_graph(len(ps))
      G = nx.karate_club_graph()
      pos = nx.spring_layout(G)
      nx.draw(G,pos,node_color='b')
  </code></pre>
  
  <p>When I run the code above, I get the following outputs.      </p>
  
  <p>Original Input Maze Image :</p>
  
  <p><img src="https://i.stack.imgur.com/qasTO.jpg" alt="Original Input Maze Image">  -- </p>
  
  <p>After Processing Image:</p>
  
  <p><img src="https://i.stack.imgur.com/OaA7B.jpg" alt="After Processing Image"> -- </p>
  
  <p>Node points on X-Y coordinates:</p>
  
  <p><img src="https://i.stack.imgur.com/oOn58.png" alt="Node points on X-Y coordinates"> -- </p>
  
  <p>Path Info:</p>
  
  <p><img src="https://i.stack.imgur.com/GRfrI.png" alt="Path Info"></p>
  
  <p>I can successfully perform image processing operations, but the search algorithm finds the shortest bird flight distance between two nodes. <strong>I want to find the shortest path along the Skeleton.</strong></p>
  
  <p>When I was working on this <a href="https://github.com/yxdragon/sknw#find-path" rel="nofollow noreferrer">github repo</a>  showed me solve this problem using the NetworkX library but I can not solve it because it does not give any detail.</p>
  
  <p><strong>How to find the shortest path along skeleton of maze image using image processing and any search algorithm ?</strong></p>
  
  <p>Thanks in advance.</p>