CV之FD之HOG:圖像檢測之基於HOG算法、簡介、代碼實現(計算圖像相似度)之詳細攻略

CV之FD之HOG:圖像檢測之基於HOG算法、簡介、代碼實現(計算圖像相似度)之詳細攻略

 

 

 

圖像檢測之基於HOG算法、簡介、代碼實現(計算圖像相似度)之詳細攻略

相關文章:CV之FD之HOG:圖像檢測之基於HOG算法、簡介、代碼實現(計算圖像相似度)之詳細攻略

1、手寫Hog特徵提取算法

import numpy as np
import cv2
 
 
#1、灰度圖像gamma校正
def gamma(img):
    return np.power(img / 255.0, 1)
 
 
#2、獲取梯度值cell圖像,梯度方向cell圖像
def div(img, cell_x, cell_y, cell_w):
    cell = np.zeros(shape=(cell_x, cell_y, cell_w, cell_w))
    img_x = np.split(img, cell_x, axis=0)
    for i in range(cell_x):
        img_y = np.split(img_x[i], cell_y, axis=1)
        for j in range(cell_y):
            cell[i][j] = img_y[j]
    return cell
 
 
#3、獲取梯度方向直方圖圖像,每個像素點有9個值
def get_bins(grad_cell, ang_cell):
    bins = np.zeros(shape=(grad_cell.shape[0], grad_cell.shape[1], 9))
    for i in range(grad_cell.shape[0]):
        for j in range(grad_cell.
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章