python - python - 如何获得沿图像线的平均像素强度并将它们绘制在图表上?
解决方案
我会使用 PIL/pillow、numpy 和 matplotlib
import numpy as np
from PIL import Image
import matplotlib.pyplot as plt
# load Image as Grayscale
i = Image.open("QWiTL.png").convert("L")
# convert to numpy array
n = np.array(i)
# average columns and rows
# left to right
cols = n.mean(axis=0)
# bottom to top
rows = n.mean(axis=1)
# plot histograms
f, ax = plt.subplots(2, 1)
ax[0].plot(cols)
ax[1].plot(rows)
f.show()
推荐阅读
- python - Python的第三方库不能在MSYS2终端上使用,如何在MSYS2终端上使用它们?
- python - 如何将 django 模型从一个项目导入另一个项目,两个项目都使用相同的数据库
- javascript - 你如何为 Wordpress 子主题编译 ES6 模块
- python - DNN 模型突然不收敛(损失低且变化不大)
- python - 当数据框只有列时,shape命令不返回列号
- vuejs2 - 拖放不适用于prime vue js中的移动屏幕
- powerbi - 计算中的错误:在用作表过滤器表达式的真/假表达式中使用了函数“CALCULATE”。这是不允许的
- javascript - 将字符串中的字符和数字拆分为数组Javascript
- python - 定期调用模块而不忘记已经定义的变量
- python - Odoo 10 将 SQL 转换为 python