Reputation: 11
Good morning, I'm implementing a code for face detection in Matlab. I'm using Histogram of oriented gradients (HOG) for feature extraction. As dataset I'm using 19x19 images: Training set: 2,429 faces, 4,548 non-faces. I'd like to know How can I tune the HOG parameters in order to work with the best feature selection process. I just selected the cellsize parameter to 4X4. This is the code I'm using:
cellSize = [4 4];
hogFeatureSize = length(hog_4x4);
trainingFeatures = [];
trainingLabels = [];
%Load Faces Training
for i=1:nface
string = [face_folder,folder_content(i,1).name];
img = imread(string);
% Apply pre-processing steps
lvl = graythresh(img);
img = im2bw(img, lvl);
features(i, :) = extractHOGFeatures(img, 'CellSize', cellSize);
trainingLabels = [trainingLabels; 1];
end
trainingFeatures = double([trainingFeatures; features]);
%Load Non-Faces Training
folder_content = dir ([non_face_folder,'*',file_ext]);
nface = size (folder_content,1);
features=[];
for i=1:nface
string = [non_face_folder,folder_content(i,1).name];
img = imread(string);
% Apply pre-processing steps
lvl = graythresh(img);
img = im2bw(img, lvl);
features(i, :) = extractHOGFeatures(img, 'CellSize', cellSize);
trainingLabels = [trainingLabels; -1];
end
trainingFeatures = double([trainingFeatures; features]);
Upvotes: 1
Views: 395
Reputation: 368
depending on the image size " the face dimension". if the image resolution and the face size is small it is better to use smaller cells. 4x4 or 8x8 but if the resolution is very high you can use larger sizes.
based on my experience I feel that 8x8 leads to good results for most of the problems I worked on. but for your problem, you need to do multiple experiments. try to perform the training and testing by using different cell sizes and based on the results you can figure out the best dimension.
Upvotes: 1