我通过从here下载的FMM工具计算铁路网络中两个城市之间的最短路径。但它无法获得对称距离(从城市A到城市B的距离不等于从城市B到城市A的距离)。在以下M代码中交换pointA和pointB来测试此问题。网络文件是1012 * 1564像素的图像。下载链接看到我的评论(我不能发布两个链接)。
我的问题:
1如何获得对称距离。
2距离的单位是多少?是重量/像素吗?
% 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');