trainingSet = imageSet(imgFolder1, 'recursive');
% Using HOG Features
cellSize = [4 4];
hogFeatureSize = length(hog_4x4);
%% Train a Digit Classifier
trainingFeatures = [];
trainingLabels = [];
for digit = 1:numel(trainingSet)
numImages = trainingSet(digit).Count;
features = zeros(numImages, hogFeatureSize, 'single');
for i = 1:numImages
img = read(trainingSet(digit), i);
% Apply pre-processing steps
lvl = graythresh(img);
img = im2bw(img, lvl);
features(i, :) = extractHOGFeatures(img, 'CellSize', cellSize);
end
我需要帮助,当我运行上面的代码时,我会在#features(i,:)中看到错误(说明分配维度不匹配)。
我实际上是尝试从大约20幅图像中提取HOG特征,并且我发现它们提取的图像数量不同。请问如何解决这个问题。谢谢。