Hey everyone,
I tried to display a heatmap over an image both using matplotlib
- which I was able to get done now. This is the result:
More particularly, I have:
- a tensor of shape
(7, 7)
with floats between 0 and 1 - let’s call it theactivation_map
- the
image
tensor of shape(3, 224, 224)
I now upsampled the activation_map
to (224, 224)
and overlayed it with a custom colormap
that is based on the gray
colormap, just making high values transparent instead of white.
However, when I plot multiple of these pictures with activation_map
, I always want them to show the same amount of pixels of the picture. Basically, I always want the highest 10.000 values of the activation_map
to be ‘1’ and the other ones to be ‘0’. How can I achieve that?
I know I need to squeeze the activation_map
to an array, sort it, then make the biggest values to ‘1’, the smallest ones to ‘0’. But how do I get the values back in the same order as they were in the original activation_map
? I need to work with the indices but I am struggling to do so…
I would be happy to receive any help, overall it is for research as this will be used in an experiment.
BR, David