seung-lab / dijkstra3d

Dijkstra's Shortest Path for 6, 18, and 26-Connected 3D (Volumetric) Image Volumes
GNU General Public License v3.0
71 stars 13 forks source link

unexpected result #3

Closed lfz closed 5 years ago

lfz commented 5 years ago

Hi, thanks for this useful function, but I found the output of this function is not as expected.

please see the example below, I am not sure this implementation is minimizing or maximizing the total weight, so I tried both. But neither of them show the expected result. Could you give some suggestions? Thank you

import matplotlib.pyplot as plt
import numpy as np
import dijkstra3d
x = np.zeros([1,200,100])+0.01
x[:,20:180,30:60] = 10
x[:,30:170,40:50] = 0.01
path = dijkstra3d.dijkstra(1/x, (0,25,35), (0,175,55))
plt.imshow(x[0].T)
plt.plot( path[:,1],path[:,2], 'ro')

image

import matplotlib.pyplot as plt
import numpy as np
import dijkstra3d
x = np.zeros([1,200,100])+0.01
x[:,20:180,30:60] = 1
x[:,30:170,40:50] = 0.01
path = dijkstra3d.dijkstra(x, (0,25,35), (0,175,55))
plt.imshow(x[0].T)
plt.plot( path[:,1],path[:,2], 'ro')

image

william-silversmith commented 5 years ago

Hi lfz,

This is really weird. I've been using this function for a while and it seems to usually be doing the right thing.

dijkstra3d.dijkstra minimizes the objective function. I'll have to take a closer look at the code to see what it's doing.

Thanks for reporting this! Will

william-silversmith commented 5 years ago

Hi lfz, the issue is that the input arrays are in C order but they need to be in F order for this library. I made a PR #4 which will accommodate C order usage. Hopefully I can get that out today.

Will

william-silversmith commented 5 years ago

1.1.0 is out! Let me know if that solves your issue. ^_^

lfz commented 5 years ago

Thank you! that's great~