問題描述
我正在使用 HoG 功能通過分類進行對象檢測.
I'm using HoG features for object detection via classification.
我對如何處理不同長度的 HoG 特征向量感到困惑.
I'm confused about how to deal with HoG feature vectors of different lengths.
我使用大小相同的訓練圖像訓練了我的分類器.
I've trained my classifier using training images that all have the same size.
現在,我正在從圖像中提取要在其上運行分類器的區域 - 例如,使用滑動窗口方法.我提取的一些窗口比訓練分類器的圖像大小要大得多.(它是根據測試圖像中可能預期的最小物體尺寸進行訓練的).
Now, I'm extracting regions from my image on which to run the classifier - say, using the sliding windows approach. Some of the windows that I extract are a lot bigger than the size of images the classifier was trained on. (It was trained on the smallest possible size of the object that might be expected in test images).
問題是,當我需要分類的窗口大于訓練圖像大小時,HoG 特征向量也比訓練模型的特征向量大很多.
The problem is, when the windows I need to classify are bigger than the training image sizes, then the HoG feature vector is also much bigger than the trained model's feature vector.
那么如何使用模型的特征向量對提取窗口進行分類呢?
So how can I use the model's feature vector to classify the extract window?
例如,讓我們取一個提取窗口的尺寸,即 360x240,并將其命名為 extractedwindow
.然后讓我們取一張我的訓練圖像,它只有 20x30,并將其命名為 trainingsample
.
For example, let's take the dimensions of one extracted window, which is 360x240, and call it extractedwindow
. Then let's take one of my training images, which is only 20x30, and call it trainingsample
.
如果我取 HoG 特征向量,像這樣:
If I take the HoG feature vectors, like this:
fd1, hog_image1 = hog(extractedwindow, orientations=8, pixels_per_cell=(16, 16), cells_per_block=(1, 1), visualise=True, normalise=True)
fd2, hog_image2 = hog(trainingsample, orientations=8, pixels_per_cell=(16, 16), cells_per_block=(1, 1), visualise=True, normalise=True)
print len(fd1)
print len(fd2)
那么這就是特征向量之間的長度差:
Then this is the difference in length between the feature vectors:
2640
616
那么這是如何處理的呢?提取的窗口是否應該按比例縮小到訓練分類器的樣本大小?還是應該根據每個提取的窗口更改/歸一化 HoG 特征的參數?還是有其他方法可以做到這一點?
So how is this dealt with? Are extracted windows supposed to be scaled down to the size of the samples the classifier was trained on? Or should the parameters for HoG features be changed/normalized according to each extracted window? Or is there another way to do this?
我個人在 python 中工作,使用 scikit-image,但我想這個問題與我使用的平臺無關.
I'm personally working in python, using scikit-image, but I guess the problem is independent of what platform I'm using.
推薦答案
正如你所說,HOG 基本上使用一個參數來確定單元格大小(以像素為單位).所以如果圖像大小發生變化,那么單元格的數量不同,那么描述符的大小就不同.
As you say, HOG basically uses a parameter that establishes the cell size in pixels. So if the image size changes, then the number of cells is different and then the descriptor is different in size.
主要做法是使用HOG就是使用像素大小相同的窗口(訓練期間和測試期間的大小相同).所以extracted window
應該和trainingsample
大小一樣.
The main approach is to use HOG is to use windows with the same size in pixels (the same size during training and also during testing). So extracted window
should be the same size of trainingsample
.
在那個參考中,一位用戶說:
In that reference, one user says:
HOG 不是尺度不變的.獲得相同長度的特征向量每張圖片不保證尺度不變性.
HOG is not scale invariant. Getting the same length feature vector for each image does not guarantee the scale invariance.
所以你應該使用相同的窗口大小...
So you should use the same window size...
這篇關于選擇/歸一化目標檢測的 HoG 參數?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!