matplotlib.pyplot中的camp

生成热度图:

import matplotlib.pyplot as plt
from PIL import Image
import numpy as np

# 使用PIL读取图像
img = Image.open('img/high/5.png')

# 将图像转换为灰度模式
img_gray = img.convert('L')

# 将PIL图像转换为numpy数组
img_array = np.array(img_gray)

# 使用matplotlib的imshow函数绘制热度图
plt.imshow(img_array, cmap='red')
plt.colorbar()

# 显示图像
plt.show()

 

 

大佬链接: https://blog.csdn.net/weixin_39580795/article/details/102622004

posted @ 2024-01-24 19:36  helloWorldhelloWorld  阅读(162)  评论(0)    收藏  举报