简体   繁体   English

2D模式搜索

[英]2D Pattern Searching

What would be a good algorithm for searching through 2D arrays of data and creating borders around data of the same sort? 搜索2D数据数据并围绕相同类型的数据创建边界的好算法是什么? The data would be random so there wouldn't be any prior knowledge of the data available, other than that it'd contain numeric values. 数据是随机的,因此除了它包含数值之外,不会有任何可用数据的先验知识。

Otherwise are there any good articles/books on the subject? 否则是否有关于这个问题的好文章/书籍?

Edit 编辑

Here is an example of what I'm trying to achieve: 这是我想要实现的一个例子:

在此输入图像描述

And the same for the two's 对于两个人来说也一样

Breadth First Search could help you here.First construct the graph G as follows: 广度优先搜索可以在这里帮助你。首先构建图G如下:

Graph G has edge (u,v) is and only if value of u-th cell=value of v-th cell. G具有边(u,v)并且仅当第u个单元的值=第v个单元的值时。

Then carrying out BFS gives nice pieces of the graph that you can conveniently mark as visited using the value of the cell. 然后执行BFS会给出很好的图形,您可以使用单元格的值方便地标记为访问过的图形。

This is a complex problem which I think is equivalent to finding the concave hull of a set of points. 这是一个复杂的问题,我认为相当于找到一组点的凹壳。

You would first have to define an equality operation for the data points so that you can determine the set of "same sort" data points. 您首先必须为数据点定义相等操作,以便您可以确定“相同排序”数据点的集合。

Having identified a set of points in that way, you then need to find the concave hull for that set of points. 通过这种方式识别出一组点后,您需要找到该组点的凹壳。

(I'm assuming you want the concave hull and not the convex hull ). (我假设你想要凹形船体而不是凸形船体 )。

Finding the concave hull is a non-trivial task. 寻找凹形船体是一项非常重要的任务。

See here for details: https://gis.stackexchange.com/questions/1200/concave-hull-definition-algorithms-and-practical-solutions 详情请见: https//gis.stackexchange.com/questions/1200/concave-hull-definition-algorithms-and-practical-solutions

If it's actually the convex hull you want, see here for an implementation in C#: 如果它实际上是你想要的凸包,请参阅此处了解C#中的实现:

http://miconvexhull.codeplex.com/ http://miconvexhull.codeplex.com/

一个天真的解决方案(适用于小数据集)是定义一个带有两个参数的比较运算符,如果它们相等则返回true,否则返回false然后简单地比较所有相邻值对(水平和垂直)和绘图如果比较返回false,则为边框。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM