Calculate the shortest path by FMM
<p>I calculate the shortest path between two cities in the railroad network by FMM tool downloaded from <a href="http://cn.mathworks.com/matlabcentral/fileexchange/24531-accurate-fast-marching" rel="nofollow">here</a>. But it can not get the symmetrical distance (the distance from city A to city B is not equal to the one from city B to city A).  Exchanging pointA and pointB in the following M-code to test this problem.  The network file is a 1012*1564 pixel image. The download link see my comment(I can not post two link).</p>

<p>My question :</p>

<p>1 how can i get the symmetrical distance.</p>

<p>2 what is the unit of the distance? Is it weight/pixel?</p>

<pre><code>% Read the network
image_rail = imread('railroad.png');
rail = (double(image_rail(:,:,1)==0));
% 90 on the rail road and 0.0001 off road
weight = 90;
SpeedImage = rail*weight+0.0001;

% Get the path
path(path,'toolbox/FastMarching_version3b');

% Location of two cities
pointA= [609;1089];
pointB = [744;1141];

% Calculate the distance map (distance to pointA)
DistanceMap= msfm(SpeedImage, pointA);

% The distance between two cities
distance_between_2cities = DistanceMap(pointB(1),pointB(2))

% Tracing the shortest path from start point to source point using distance map.
ShortestLine=shortestpath(DistanceMap,pointB,pointA);

% Show the map
rgb_rail = ones(size(rail));
rgb_rail (rail == 1)= 0.1;
imshow(rgb_rail) % Test for railroad and road matrix

% Plot the shortest route
hold on, plot(ShortestLine(:,2),ShortestLine(:,1),'r');

% Plote the pointB and pointA
plot(pointB(2),pointB(1),'.','MarkerSize',30,'color','blue');
plot(pointA(2),pointA(1),'.','MarkerSize',30,'color','red');
</code></pre>

<p><a href="http://i.stack.imgur.com/qly6a.png" rel="nofollow">enter image description here</a></p>