假设我有 3 个(或 100 个)具有 dim=2 和 shape=(x, y) 的 ndarray,它们相互堆叠。
对于另一个数组下方的数组中的每个索引,与上面的值相比,下面的值更小,如下所示:
A =
[ 0 0 1 1
0 0 0 1
0 0 0 0
0 0 0 0 ]
B =
[ 2 2 2 2
2 2 2 2
1 2 2 2
1 1 2 2 ]
C =
[ 3 4 4 3
3 4 4 4
2 3 4 4
2 2 2 4 ]
给定一个数字(例如 1.5),我想找到
for each (x, y) of the ndarrays:
(1) the index of the stacked array, that has the biggest value below and
(2) the index of the stacked array, that has the smalest value above the number
that is, the sourunding "bouding layer" of the number)
对于上面的示例数组,这将是: 低于阈值的层的索引
I_biggest_smaller_number =
[ 0 0 0 0
0 0 0 0
1 0 0 0
1 1 0 0 ]
高于阈值的层数
I_smallest_bigger_number =
[ 1 1 1 1
1 1 1 1
2 1 1 1
2 2 1 1]
以最有效的方式使用 numpy. 任何帮助将不胜感激:)