python实现人脸识别之一实现图像梯度图

python实现人脸识别

1.工具和以来模块

我的python版本是3.7,IDE是PyCharm

所以来模块是skimage,matplotlib

引入skimage模块有问题的话参考:https://blog.csdn.net/ycc297876771/article/details/80271403

2.导入所需要的模块

3.引入图片

引入图片,将图片转化为灰度图像

4.计算HOG

5.作出灰度梯度图像

python实现人脸识别之一实现图像梯度图_第1张图片

运行结果如下:

python实现人脸识别之一实现图像梯度图_第2张图片

完整代码如下:

# 导入函数库
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人脸识别,请见谅。。。

 

 

你可能感兴趣的:(python,人脸识别)