使用
从图像中提取HOG功能时bin_n = 16 # Number of bins
def hog(img):
gx = cv2.Sobel(img, cv2.CV_32F, 1, 0)
gy = cv2.Sobel(img, cv2.CV_32F, 0, 1)
mag, ang = cv2.cartToPolar(gx, gy)
bins = np.int32(bin_n*ang/(2*np.pi)) # quantizing binvalues in (0...16)
bin_cells = bins[:10,:10], bins[10:,:10], bins[:10,10:], bins[10:,10:]
mag_cells = mag[:10,:10], mag[10:,:10], mag[:10,10:], mag[10:,10:]
hists = [np.bincount(b.ravel(), m.ravel(), bin_n) for b, m in zip(bin_cells, mag_cells)]
hist = np.hstack(hists) # hist is a 64 bit vector
return hist
path1='d:\\Emmanu\\project-data\\training-set\\1\\'
listing1 = os.listdir(path1)
for file in listing1:
img = cv2.imread(path1 + file)
h=hog(img)
print h
我得到一长串列表,如
列表中的每个数字表示什么?
答案 0 :(得分:1)
此列表中的一个条目给出了给定单元格(图像的某个区域)和某个区域内的所有渐变的大小总和(由16个梯度的角度决定)你的例子中的箱子)