4

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

original image

and this is the (hand-drawn) minimal path in red, from UL to LR corner (black boundaries serve as zero-weight padding):

example minimum path

I found that matlab has the graydist function just for this; is there something similar in ndimage/scikit-image/whatever? I found scipy.ndimage.morphology.distance_transform_edt 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.

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.

Glorfindel
  • 21,988
  • 13
  • 81
  • 109
eudoxos
  • 18,545
  • 10
  • 61
  • 110

1 Answers1

6

This type of dynamic programming is available in scikit-image as route_through_array and shortest_path: http://scikit-image.org/docs/dev/api/skimage.graph.html

Stefan van der Walt
  • 7,165
  • 1
  • 32
  • 41
  • 1
    I wonder why most image processing libs/packages/modules show no images in their docs?! :) Thanks a lot! – eudoxos Oct 04 '16 at 21:28
  • Take a look at our gallery: http://scikit-image.org/docs/dev/auto_examples/ We don't have examples for *all* functionality, but at least for a fair percentage. – Stefan van der Walt Oct 05 '16 at 18:22
  • Being a maintainer of documentation of another project, I know it is a hard work, and I am grateful for your efforts. Though what I meant is to have an image example (where applicable) at the same place where the function is documented by sphinx, not everything together in the gallery. Matplotlib has examples for most functions in the API documentation ([Axes API](http://matplotlib.org/api/axes_api.html), for instance) which is very handy. – eudoxos Oct 07 '16 at 07:59
  • Ah, gotcha. Yes, we can look into including the outputs of examples right into the docs; I've filed an issue here: https://github.com/scikit-image/scikit-image/issues/2332 – Stefan van der Walt Oct 07 '16 at 18:29