Anyone knows an algorithm for finding “shapes” in 2d arrays?

后端 未结 5 1386
不思量自难忘°
不思量自难忘° 2021-02-04 08:25

Let\'s take this map, where \'#\' illustrates a taken square and \'.\' illustrates a free square:

1 . # # # . .
2 . # . . # .
3 # . . . . #
4 . # # # . .
5 . . . . .          


        
5条回答
  •  粉色の甜心
    2021-02-04 08:45

    I think this question can be reduced to a convex hull problem if we consider each # as point x,y then convex hull be give us the x,y of all the # which are absent

    http://en.wikipedia.org/wiki/Convex_hull

    I will try to code it in leisure ..

提交回复
热议问题