有两个光栅,如下所示。仅由四个值组成的值[1,2,3,4]。另一个由800到2500之间的值组成。问题是遍历所有光栅-1区域并找到位于每个区域或段内部的光栅-2的最大值
理论上,它看起来很简单,但我找不到实现它的方法。我正在阅读scikit image
文档,我越来越困惑了。理论上,这将是:
for i in raster1rows:
for j in i:
# where j is a part of closed patch, iterate through the identical
# elements of raster-2 and find the maximum value.
这个问题还有一个固有的问题,我不能把它作为一个不同的主题发表。如您所见,raster-1上有许多孤立的像素,可以将其解释为一个区域并产生许多额外的最大值。为了防止这种情况,我使用了:
raster1 = raster1.astype(int)
raster1 = skimage.morphology.remove_small_objects(raster1 , min_size=20, connectivity=2, in_place=True)
但是raster-1
似乎没有效果
移除我所做的小物件
它给了我很好的结果
要找到我所做的每个封闭部分内的最大标高:
我得到了我想要的结果
相关问题 更多 >
编程相关推荐