Uncertainty map

I have an uncertainty matrix, how can we convert it into an image showing high uncertainty with dark color?

How is this matrix ensembled? What is the maximum value (probably 1) and is a high uncertainty represented by a high value? Is your matrix stored inside a tensor or something else (like numpy array)?

matrix is inside a tensor, yes max value is 1, and high uncertainty is represented by high value.

What is the tensors shape?

My model’s output is a 12 channel output(12 x 512 x 512), containing scores, but i am taking max among those, so the final size is (1 x 512 x 512).

Probably you might be able to achieve this with something simple like this:

from torchvision.utils import save_image

# assuming your uncertainty matrix is stored in variable matrix 
save_image(1-matrix, "SPECIFY/YOUR/SAVE/PATH/uncertainty.png")

EDIT: Or if you want to plot it directly (e.g. by using matplotlib) you could do something like this:

from matplotlib import plot as plt

matrix_npy = (1-matrix).cpu().detach().numpy().squeeze()
plt.imshow(matrix_npy, cmap='gray') 

Next EDIT: it might be worth considering to save all 12 channels as separate uncertainty map since otherwise it could be hard to trace back a high uncertainty

I did this, but the results are not that much visible in the image,can you tell me what’s wrong? one more thing the scores were normalized using x=(x-min(x))/(max(x)-min(x)).Below is the image