I've got a heat map numpy array with shape (600,400). The heatmap represents probabilities of detection. In my case, the probability of face detections in an image. My goal is to take this heatmap and get the coordinates (X and Y) where the highest probability occurs.
I've solved this for the case of a single face. The code for that is the following:
face_location = np.unravel_index(heatmap.argmax(), heatmap.shape)
print("Face location: " + str(face_location))
But in some cases there are multiple faces. I don't know how to adjust the algorithm to return multiple "hottest area". The issue is that any one hot area will be surrounded by gradually less hot areas. And so it's possible that after the hottest area, the next top 10 will all be right beside the initial point.
How can I adjust the algorithm to look for multiple hot areas? It's ok to assume that they won't be right beside each other.
heatmap = [[ 2.00299415e-04 2.03753079e-04 8.17560707e-04 ..., 2.23556344e-04
1.98958180e-04 9.92935777e-01]
[ 2.00642273e-04 2.04473894e-04 8.19963054e-04 ..., 2.24148811e-04
1.99438742e-04 9.92921114e-01]
[ 2.01056406e-04 2.05344462e-04 8.22864589e-04 ..., 2.24864416e-04
2.00019145e-04 9.92903233e-01]
...,
[ 7.28193991e-05 -2.73474743e-05 2.95096161e-05 ..., 5.96550672e-05
1.98282614e-05 9.99637246e-01]
[ 7.34055429e-05 -2.72389279e-05 3.02382941e-05 ..., 5.98490733e-05
2.04356711e-05 9.99619305e-01]
[ 7.37556256e-05 -2.71740992e-05 3.06735128e-05 ..., 5.99649393e-05
2.07984649e-05 9.99608397e-01]]