python - 从直方图中确定最常见的字体大小
问题描述
我们如何使用黑色分量的直方图找到文档图像中出现频率最高的字体大小?下面是显示图像直方图的代码:
import matplotlib.pyplot as plt
import numpy as np
import os.path
if __name__ == '__main__':
image_counter = 1
while True:
if not os.path.isfile(str (image_counter) + '.png'):
break
image_path = str(image_counter) + '.png'
image = plt.imread(image_path)
#Display Histogram
#print(image)
#print(image.ravel())
n, bins, patches = plt.hist(image.ravel(), bins = 256)
plt.title('Image Patch # ' + str(image_counter))
plt.xlabel('Grey Value')
plt.ylabel('Frequency')
window = plt.get_current_fig_manager()
window.canvas.set_window_title('Histogram')
plt.show()
image_counter = image_counter + 1
解决方案
推荐阅读
- spring - 服务器和本地主机字符集之间不兼容
- python-3.x - 使用 imshow() 在 matplotlib 直方图上记录 x 轴
- php - mysql LIKE 与双百分比
- python - 使用 pandas 查找数据框列中的前 3 个
- php - 无法使用 PHP 代码创建文件
- php - Mysql - 查看一个值是否已经存在
- ios - Xcode 找不到文件,但文件包含在目标中
- c# - 从使用存储过程的 TableAdapter.Update() 方法返回值
- django - 在模板中访问内联表单集的父级?
- python - (Debian) Dragonboard 410c:Tensorflow 不是这个平台上支持的轮子