0001
0002 [A, map] = imread('r2.bmp', 'BMP');
0003 image(A), hold on
0004 roadPoints = findRoads(A);
0005 crossingPoints = [
0006 128 156
0007 131 156
0008 554 155
0009 540 310
0010 369 389
0011 366 391
0012 515 530];
0013 [node1Node2Road_noCost, positionRoad_no, markedRoad, nodes] = identifyRoads(roadPoints, crossingPoints);
0014 [sx, sy] = size(A(:,:,1));
0015 costMap = 3.*ones(sx,sy);
0016 for i = 1:sx
0017 for j = 1:sy
0018 if (roadPoints(i,j) == 1)
0019 costMap(i,j) = 1;
0020 end;
0021 end;
0022 end;
0023 clf
0024 vi = [639 239];
0025 fi = [669 131];
0026 image(A), hold on
0027 drowVi(vi(2), vi(1));
0028 drowRect(fi(2), fi(1));
0029
0030
0031 [cost, path, nodes, positionRoad_no, node1Node2Road_noCost] = findShortestPath(roadPoints, positionRoad_no, [fi 0], [vi 0], nodes, node1Node2Road_noCost, costMap);
0032 plot(path(:,2), path(:,1))
0033
0034
0035
0036
0037
0038
0039
0040
0041
0042
0043
0044
0045
0046
0047
0048
0049