I want to use GradCAM activation to infer the obeject location on the image, it is not really a problem if there is only one contour heatmap since I can simply use argmax to get that. But I want to be able to grab more than one heatmap hoping that with more than one heatmap we can point the location more accurately.
Here is the example
import matplotlib.pyplot as plt
activation_map = [[0.0724, 0.0615, 0.0607, 0.0710, 0.0000, 0.0000, 0.0154],
[0.1111, 0.0835, 0.0923, 0.0409, 0.0000, 0.0000, 0.0000],
[0.0986, 0.0860, 0.1138, 0.0706, 0.0144, 0.0000, 0.0000],
[0.1134, 0.1109, 0.2244, 0.3414, 0.2652, 0.2708, 0.1664],
[0.1165, 0.1620, 0.5605, 0.7064, 0.4593, 0.6628, 0.6103],
[0.0852, 0.2324, 1.0000, 0.8605, 0.5095, 0.8457, 0.8332],
[0.0349, 0.2422, 0.9287, 0.5717, 0.2054, 0.4749, 0.6983]]
plt.imshow(activation_map)
After I rescale this activation map to proper scaling it looks something like this
import cv2
activation_map_resized = cv2.resize(np.array(activation_map), (64, 64))
plt.imshow(activation_map_resized)
I want to be able to get the point around (22, 50) and (55, 50).
Any method I can use to find the center of that two contour heatmap efficiently? I can imagine using gradient or some clustering, but I'm not sure if it is the most effiient method to use.