title: Intensity-weighted minimal path between 2 points in grayscale image
body: <p>I want to determine minimum path between two specific points in an image, i.e. the path for which sum of distances between adjacent pixels weighted by pixel intensity (greyscale) will be minimized. For instance, this picture shows the input image</p>
  <p><a href="https://i.stack.imgur.com/6hR24.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/6hR24.jpg" alt="original image" /></a></p>
  <p>and this is the (hand-drawn) minimal path in red, from UL to LR corner (black boundaries serve as zero-weight padding):</p>
  <p><a href="https://i.stack.imgur.com/6Y2Wb.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/6Y2Wb.jpg" alt="example minimum path" /></a></p>
  <p>I found that matlab has the <a href="https://www.mathworks.com/help/images/ref/graydist.html" rel="nofollow noreferrer">graydist</a> function just for this; is there something similar in ndimage/scikit-image/whatever? I found <a href="https://docs.scipy.org/doc/scipy-0.14.0/reference/generated/scipy.ndimage.morphology.distance_transform_edt.html#scipy.ndimage.morphology.distance_transform_edt" rel="nofollow noreferrer">scipy.ndimage.morphology.distance_transform_edt</a> but I am not sure if and how to use it for this purpose. It is OK if the algorithm returns only one of non-unique minima.</p>
  <p>I am not interested in implementation hints, it is a fairly straightforward task algorithmically (at least the naive implementation using e.g. dynamic programming), I am looking for (combination of) already coded routines to accomplish this.</p>