登录 |  注册 |  繁體中文


绘制图像直方图

分类: python 颜色:橙色 默认  字号: 阅读(562) | 评论(0)

绘制图片直方图

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

img=np.array(Image.open(./img/lena.png).convert(L))

plt.figure("lena")
arr=img.flatten()
n, bins, patches = plt.hist(arr, bins=256, density=1, facecolor='blue', alpha=0.75)  
plt.show()

效果如下




姓 名: *
邮 箱:
内 容: *
验证码: 点击刷新 *   

回到顶部