Unable to perform assignment because the size of the left side is 1-by-4680 and the size of the right side is 1-by-9360, how can i solve this error?
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
%%Extract HOG Features for training set
trainingFeatures = zeros(size(training,2)*training(1).Count,4680);
featureCount = 1;
for i=1:size(training,2)
for j = 1:training(i).Count
trainingFeatures(featureCount,:) = extractHOGFeatures(read(training(i),j));
trainingLabel{featureCount} = training(i).Description;
featureCount = featureCount + 1;
end
personIndex{i} = training(i).Description;
end
5 commentaires
Walter Roberson
le 10 Mai 2021
Modifié(e) : Walter Roberson
le 11 Mai 2021
Shefali Patil
le 11 Mai 2021
same code i have in my project and i m getting error in this line :
trainingFeatures(featureCount,:) = extractHOGFeatures(read(training(i),j));
i am not getting what changes to do here, what to type instead of 4680 ? how can we say what is the size of every image ?
Réponses (1)
Walter Roberson
le 11 Mai 2021
Modifié(e) : Walter Roberson
le 11 Mai 2021
According to the documentation, the returned size is https://www.mathworks.com/help/vision/ref/extracthogfeatures.html#btxscw9-features
HOG feature length, N, is based on the image size and the function parameter values.
The cell size defaults to 8 x 8 according to https://www.mathworks.com/help/vision/ref/extracthogfeatures.html#btxscw9-CellSize
The BlockSize defaults to 2 x 2 according to https://www.mathworks.com/help/vision/ref/extracthogfeatures.html#btxscw9-BlockSize
Numbins defaults to 9 according to https://www.mathworks.com/help/vision/ref/extracthogfeatures.html#btxscw9-NumBins
BlockOverlap defaults to ceil(BlockSize/2) according to https://www.mathworks.com/help/vision/ref/extracthogfeatures.html#btxscw9-BlockOverlap ; with the default BlockSize of 2 x 2 that would be a default of 1 x 1
So we can calculate
%example image
I = imread('flamingos.jpg');
%the calculation
BlocksPerImage = floor(([size(I,1), size(I,2)] ./ 8 - 2) ./ (8 - 1) + 1)
and then
N = prod([BlocksPerImage, [8 8], 9])
Now let us try it:
output = extractHOGFeatures(I);
size(output)
The difference suggests a factor of 3 due to 3 color planes. I will investigate.
1 commentaire
Walter Roberson
le 11 Mai 2021
Unfortunately the routine that does the final computation is a built-in so I cannot determine exactly where the difference is coming from.
I will file a request to have the documentation expanded for the truecolor case.
Voir également
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!