I'm a beginner in working with images in python and I'm trying to display 2D array, 500px x 500px, array((500, 500)), which I usually display as an grayscale image as a color image, in heatmap.
我是python中处理图像的初学者,我试图在热图中显示2D数组,500px x 500px,数组((500,500)),我通常将其显示为灰度图像作为彩色图像。
to be displayed like this:
要显示如下:
I tried but I couldn't find the answers in the internet, and what I found didn't work for me. Please help.
我试过但我在互联网上找不到答案,我发现的东西对我不起作用。请帮忙。
I don't really have much code, I only know that this one:
我真的没有太多代码,我只知道这个:
my_img = plt.imread(filename)
plt.imshow(my_img, cmap="hot")
doesn't work, it displays the same image, in grayscale.
不起作用,它以灰度显示相同的图像。
1 个解决方案
#1
0
try giving pcolor a try. It's the more usual analogy to a "heatmap". imshow
is more aligned with the display of images true to the color values in the array. The fact that your ideal image is inverted from your practice image also tells me pcolor might be a better choice.
尝试尝试pcolor。这是“热图”的更常见的类比。 imshow与图像的显示更加一致,与图像中的颜色值相对应。您的理想图像与练习图像相反的事实也告诉我pcolor可能是更好的选择。
#1
0
try giving pcolor a try. It's the more usual analogy to a "heatmap". imshow
is more aligned with the display of images true to the color values in the array. The fact that your ideal image is inverted from your practice image also tells me pcolor might be a better choice.
尝试尝试pcolor。这是“热图”的更常见的类比。 imshow与图像的显示更加一致,与图像中的颜色值相对应。您的理想图像与练习图像相反的事实也告诉我pcolor可能是更好的选择。