Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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? 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:

enter image description here

And the same for the two's

like image 808
Alex Avatar asked Oct 27 '25 13:10

Alex


1 Answers

Breadth First Search could help you here.First construct the graph G as follows:

Graph G has edge (u,v) is and only if value of u-th cell=value of v-th cell.

Then carrying out BFS gives nice pieces of the graph that you can conveniently mark as visited using the value of the cell.

like image 57
Aravind Avatar answered Oct 30 '25 04:10

Aravind