The image array shape is (540, 960, 3)
, and it like this:
img_rgb = [[[ 95 71 71]
[ 95 71 71]
[ 95 71 71]
...
[182 171 181]
[182 171 181]
[182 171 181]]
[[ 95 71 70]
[ 95 71 70]
[ 95 71 71]
...
[183 172 182]
[183 172 182]
[183 172 182]]
[[ 95 72 70]
[ 95 71 70]
[ 95 71 71]
...
[183 172 182]
[183 172 182]
[183 172 182]]
...
[[ 36 35 45]
[ 36 35 45]
[ 36 35 45]
...
[ 49 45 50]
[ 49 45 50]
[ 49 45 50]]
[[ 36 35 45]
[ 36 35 45]
[ 36 35 45]
...
[ 49 45 50]
[ 49 45 50]
[ 49 45 50]]
[[ 36 35 45]
[ 36 35 45]
[ 36 35 45]
...
[ 49 45 50]
[ 49 45 50]
[ 49 45 50]]]
And I want to get elements by indices
that indicate the each element index, and the indices
like this:
indices = [
[0, 0], [0, 1], [0, 2]
]
Expected output
[
[ 95 71 71],
[ 95 71 71],
[ 95 71 71],
]
There are tow similar question in those link, one is Python numpy 2D array sum over certain indices, and another is Finding the (x,y) indexes of specific (R,G,B) color values from images stored in NumPy ndarrays.
It got a IndexError: too many indices for array
When I tried question one by img_rgb[tuple(indices)]
.