2016-05-01 39 views
0

當使用「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 

我得到的名單像

enter image description here

什麼是列表中的每個數字表示一長串的圖像Extracing HOG特徵?

回答

1

該列表中的一個條目給出了給定單元格(圖像的一個區域)內的所有漸變的大小總和以及一個特定的bin(它由放入的漸變的角度決定)在你的例子中有16個bin)

相關問題