I have a 2D array (array
) of length 10x10
array = ImageData[RandomImage[10, 10]];
and I have a list of indices for the desired array elements.
desired = {{1, 3}, {1, 4}, {1, 5}, {1, 6}, {2, 3}, {2, 4}, {2, 5}, {2, 6},
{3, 3}, {3, 4}, {3, 5}, {3, 6}, {4, 3}, {4, 4}, {4, 5}, {4, 6}, {5,
2}, {5, 3}, {5, 4}, {5, 5}, {5, 6}, {6, 2}, {6, 3}, {6, 4}, {6,
5}, {6, 6}, {7, 3}, {7, 4}, {7, 5}, {7, 6}, {8, 3}, {8, 4}, {8,
5}, {8, 6}};
One way to access the desired elements is array[[desired[[i,1]],desired[[i,2]]]]
.
But I think there must be some better approaches to do this. Therefore, my question is: how smartly can this be done?
desired[[i]]
? $\endgroup$