我试图找到一种方法来确定环绕二维平面上存在的连续区域的最远方(最东边、最西边等)。左下角的点是 [0,0],例如,右上角的点是 [244,244] 我在下面包含了我的数据示例。请注意,出现在 4 个角上的深灰色区域是同一区域。
通过检查给定区域内的每个方 block 并记录具有最高 X 的方 block ,我能够用我的数据解决这个问题。我也进行了相同的搜索,除了限于 [0,width * .5]。但是,此解决方案仅适用于我的区域主要围绕一个点而不是又长又薄的区域。
@maraca 在评论中概述了一种方法,我认为可以提炼为:
* find an edge square
* assign 0 to current square
* walk around the edges, adding 1 when travelling east, -1 when travelling west (or north/ south)
* the square with the highest value is the furthest east, the square with the lowest value is the furthest west
最佳答案
@maraca 在评论中概述了一种方法,我认为可以提炼为:
* find an edge square
* assign 0 to current square
* walk around the edges, adding 1 when travelling east, -1 when travelling west (or north/ south)
* the square with the highest value is the furthest east, the square with the lowest value is the furthest west
效果很好。谢谢!
关于algorithm - 如何找到 "Eastern"区域的大部分点位于环绕二维平面内,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48329918/