我的python版本是3.7,IDE是PyCharm
所以来模块是skimage,matplotlib
引入skimage模块有问题的话参考:https://blog.csdn.net/ycc297876771/article/details/80271403
引入图片,将图片转化为灰度图像
运行结果如下:
完整代码如下:
# 导入函数库
from skimage import io, color
from skimage.feature import hog
import matplotlib.pyplot as plt
# 导入图片
image = io.imread("E://file/renlian3.jpg")
image = color.rgb2gray(image)
# 计算HOG
arr, hog_img = hog(image, visualise=True, orientations=4) # orientations --方向
# 作图
fig, (ax1, ax2) = plt.subplots(1, 2, figsize=(8, 4))
ax1.imshow(image, cmap=plt.cm.gray)
ax2.imshow(hog_img, cmap=plt.cm.gray)
plt.show()
刚刚学习python人脸识别,请见谅。。。