如何在给定的地图(sattalite图像)中找到最短路径以使用C# [英] how to find shortest path in given map(sattalite image) for using C#

查看:98
本文介绍了如何在给定的地图(sattalite图像)中找到最短路径以使用C#的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望使用C#以及如何封锁道路以及如何在给定地图中找到最短路径....
我使用Google地图,并在选定区域中创建了自己的路线图.

i hope using C# and how to blocked road and how to find shortest path in given map....
i use google map and my own create road map in selected area.

推荐答案

作为一种算法,请尝试此方法.现在,我假设您正在按照指示使用Google地图.
1)将地图作为图像(元文件)读取.

2)在Google地图中,道路应具有特定值(或狭窄动态范围内的值).例如,黄色的较大道路和白色的较小道路.

3)首先,进行细化处理(形态图像处理).因此,地图上的对象成为一个或多个单个像素或单个像素(道路)的连接.另外,请参见图像的骨架化.
4)然后,定义出发点A和终点B.将这些坐标保存在一些变量中.同时,为您要跟踪的道路定义像素值(例如,对应于黄色像素的像素值).实际上,这是图像处理中的标签问题.有时称为连接性标记.主要思想是从图像中提取相同的对象或相似的区域.
5)现在,该开始标记了(即,将当前像素与其周围的八个像素-候选像素进行比较),如果它们的值匹配,则将其计数为"1",然后将其保存一些位置(作为匹配像素) .通常,在八个像素中,只有一个像素应与当前像素匹配(我们进行了细化处理).
现在,匹配的候选像素变为当前像素".这是一个迭代过程,重复此过程.最后,如果一切正常,您将到达终点B.到达终点时,停止迭代并计算所有匹配像素",以便获得距离(因为您知道像素的大小.即,在地图或卫星图像中,每个像素对应于某个区域,例如XX平方米.我们称此为空间分辨率.现在,您获得了A和B之间的路径和距离,即[distance-1:D1].
6)沿X方向翻转图像,然后将其旋转180度.现在,先前的终点B成为新的出发点A.再次重复步骤4)和5).现在,您在新的A和B之间有了一条路径.如果A和B之间有一条以上的道路,则有两条路径-第二距离[distance-2:D2].如果只有一条道路,则与D1的距离几乎相同.
7)然后,C#,System.Math.Min(D1,D2).找到答案了.
As an algorithm, please try this. Now, I am assuming that you are using Google-map as you indicated.
1) Read the map as an image (metafile).

2) In Google map roads should have a specific value (or values in a narrow dynamic range). For example, larger roads in yellow and smaller roads in white colors.

3) First, do a thinning-processing (a morphological image processing). Thus, objects on the map become single pixel (s) or connection of the single pixels (roads). Also, see skelotonization of an image.
4) Then, define the departure point A and terminal point B. Save these coordinates in some variables. At the same time, define the pixel value for the road you are going to track (for example, a pixel value corresponding to a yellow pixel). Actually, this is a labeling issue in image processing. Sometimes it is called connectivity labeling. The main idea is extracting same object(s) or similar areas from an image.
5) Now, it’s time to start labeling (namely, compare the current pixel with its surrounding eight pixels- candidate pixels), if their values is a match count it as "1", and save it some place (as Matched Pixels). In general, among the eight pixels, only one pixel should be matched to the Current pixel (We did thinning-processing).
Now, the candidate pixel, which was matched, becomes the "Current Pixel". This is an iteration process, repeat this. At the end, if everything is OK, you will reach the Terminal Point B. When, you got in the terminal point, stop the iteration and count all Matched Pixels, so that you can get distance (because you know the pixel’s size. Namely, in maps or satellite images, each pixel is corresponding to some area, e. g., XX- square meters. We call this spatial resolution). Now, you got a path and distance between A and B, [distance-1:D1].
6) Flip the image in X-direction, then rotate it 180-degrees. Now, the previous terminal point B becomes the new Departure point A. Repeat the steps of 4) and 5) again. Now, you got a path between the new A and B. If there are more than one road between A and B, you got two paths-the second distancel [distance-2: D2]. If there is only one road, you got almost the same distance with D1.
7) Then, C#, System.Math.Min(D1,D2). You got the answer.


Soooo,您想查找一张图像上从A点到B点的最短路径吗?没有路口和路线上的数据?
Soooo, you want to find the shortest path from point A to point B on an image alone?? No data on intersections and routes??


这篇关于如何在给定的地图(sattalite图像)中找到最短路径以使用C#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆