Python中常用的图像特征

数据链接:https://pan.baidu.com/s/1cz8SihL2HYh_cFudc7y07Q 密码:tr35

import cv2
import numpy as np

1、颜色特征

img_gray_data = cv2.imread('./images/messi.jpg', cv2.IMREAD_GRAYSCALE)
hist, bins = np.histogram(img_gray_data.ravel(), bins=50)
print(hist)
print(bins)

2、SIFT 特征

img = cv2.imread('./images/messi.jpg', cv2.IMREAD_GRAYSCALE)
sift = cv2.xfeatures2d.SIFT_create()
kp, desc = sift.detectAndCompute(img, None)
img_w_kp = cv2.drawKeypoints(img, kp, None, flags=cv2.DRAW_MATCHES_FLAGS_DRAW_RICH_KEYPOINTS)
cv2.imshow('img_w_kp', img_w_kp)
cv2.waitKey(0)
cv2.destroyAllWindows()
print(desc.shape)
print('该图像共有{}个特征点,每个特征点对应的特征维度是{}'.format(desc.shape[0], desc.shape[1]))

3、HOG 特征

img = cv2.imread('./images/messi.jpg', cv2.IMREAD_GRAYSCALE)
hog = cv2.HOGDescriptor()
hist = hog.compute(img)
print('HOG特征维度:', hist.shape)

你可能感兴趣的:(深度学习)