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)
%%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
Shefali Patil
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 ?

Connectez-vous pour commenter.

Réponses (1)

Walter Roberson
Walter Roberson le 11 Mai 2021
Modifié(e) : Walter Roberson le 11 Mai 2021
HOG feature length, N, is based on the image size and the function parameter values.
N = prod([BlocksPerImage, BlockSize, NumBins])
BlocksPerImage = floor((size(I)./CellSize – BlockSize)./(BlockSize – BlockOverlap) + 1)
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)
BlocksPerImage = 1×2
18 23
and then
N = prod([BlocksPerImage, [8 8], 9])
N = 238464
Now let us try it:
output = extractHOGFeatures(I);
size(output)
ans = 1×2
1 695520
The difference suggests a factor of 3 due to 3 color planes. I will investigate.
  1 commentaire
Walter Roberson
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.

Connectez-vous pour commenter.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by