【问题标题】:How do I plot a Histogram of Oriented Gradients?如何绘制方向梯度的直方图?
【发布时间】:2019-05-23 03:32:19
【问题描述】:

如何使用 matplotlib 绘制 HOG?我不知道人们是如何像下面的例子那样绘制它的:

https://gurus.pyimagesearch.com/lesson-sample-histogram-of-oriented-gradients-and-car-logo-recognition/#tour_modal

我浏览了 matplotlib 网站,但没有找到合适的例子。 ¿ 有谁知道如何绘制它或者我可以在哪里学习它?

我现在一直在尝试这个,但没有运气。 https://matplotlib.org/3.1.0/gallery/statistics/histogram_histtypes.html#sphx-glr-gallery-statistics-histogram-histtypes-py

我只需要识别HOG的9个bin内的像素分布和笔画的度数。

【问题讨论】:

标签: python matplotlib scikit-learn scikit-image


【解决方案1】:

直方图可以让我们得到图像每一级灰度的相对频率,在opencv中我们可以这样得到直方图:

带垃圾箱:

image = cv2.imread('example.jpg')
imagex = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)

plt.hist(imagex.ravel(), bins=8, range=(0,255))
plt.show()

您将获得一个基于 bin 的直方图, 但如果你想获得图像的所有直方图,请尝试:

image = cv2.imread('myimage.jpeg')
imagex = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
plt.hist(imagex.ravel(),256,[0,256]);
plt.show()

最好的问候!

【讨论】:

    猜你喜欢
    • 2016-07-23
    • 2013-06-22
    • 1970-01-01
    • 2012-07-15
    • 2011-08-01
    • 2017-12-10
    • 2015-01-21
    • 2013-11-08
    相关资源
    最近更新 更多