如何在 WPF 中将位图转换为路径集合(在代码中而不是 XAML 中)
我有一个占用网格,有 3 个状态 - 已占用、空闲、未知。占用网格是一个简单的二维状态数组。网格表示平面图,其中占用 = 墙壁,空闲 = 开放楼层,未知 = 墙后面或未映射的内容。该网格的宽度为 800x800,每个单元代表现实世界的 5 厘米。
我想把它变成一个 WPF 路径形状。然后我可以在屏幕上进行操作,允许用户添加墙壁(通过绘制线条),并最终导出为某种形式的 CAD 标准/SVG/等。
我开始使用可写位图,并且可以创建完美的网格图片,但是位图不是路径,而且我的一些线条是锯齿状的或未连接的。
我正在寻找有关如何将此网格或位图转换为干净的 wpf 形状的想法。直线、多边形、折线或路径都会让我非常高兴,因为一旦我拥有了这些,我就可以做任何事情。有什么想法吗?
I have an occupancy grid that has 3 states - Occupied, Free, Unknown. Occupancy grid is a simple 2 dimensional array of states. The grid represents a floor plan where Occupied=Wall, Free=Open Floor, Unknown=what's behind the wall or not mapped. This grid is say 800x800 wide with each cell representing 5cm of the real world.
I want to take this and make it into a WPF Path Shape. Then I can then manipulate on the screen, Allow a user to add walls (by drawing lines), and eventually export to some form of CAD standard/SVG/etc.
I started playing with writable bitmaps and can create a perfect picture of the grid, how ever a bitmp isn't a path, and some of my lines are jagged or unconnected.
I am looking for ideas on how to translate this grid, or thebitmap, into clean wpf shapes. Lines, Polygons, Polylines, or Paths would all make me very happy becuase once I have those I can do anything. Any ideas?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果你的墙壁只有一些基本的几何形状(线条,其他像圆形变得更加复杂),你可能需要使用 霍夫变换 或其他一些变换,具体取决于您的图像的外观。如果我正确理解您的图像只有三种颜色,您可能不必使用某些边缘检测算法。
编辑:如果“占用”状态仅代表墙壁的薄表面,那么这就是您所需要的。您会得到墙壁的线条(界定自由/未知区域)
If your walls are only in some basic geometrical shapes (lines, others like circles get much more complicated) you might want to use Hough transform or some other transform, depending how your images look like. If I understand it correctly that your images have only three colours you might not have to use some edge detection algorithm.
Edit: If the Occupied state represents only thin surfaces of walls that is all you need. You would get lines for your walls (delimiting free/unknown areas)