I have a bounding box that sits inside a 2-d array, where areas outside of the bounding box are marked as 'nan'. I am looking for a way to locate the 4 corners of the bounding box, aka, the indices of the values adjacent to the 'nan' value. I can do it in a 'for-loop' way, but just wonder if there are faster ways to do so.
For the following example, the results should return row index 2,4, and column index 1, 4.
[[nan,nan,nan,nan,nan,nan,nan],
[nan,nan,nan,nan,nan,nan,nan],
[nan, 0, 7, 3, 3, nan,nan],
[nan, 7, 6, 9, 9, nan,nan],
[nan, 7, 9, 10, 1, nan,nan],
[nan,nan,nan,nan,nan,nan,nan]]
Thanks.