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 (최근 30일)
%%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
Shefali Patil
Shefali Patil 2021년 5월 11일
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 ?

댓글을 달려면 로그인하십시오.

답변 (1개)

Walter Roberson
Walter Roberson 2021년 5월 11일
편집: Walter Roberson 2021년 5월 11일
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
Walter Roberson
Walter Roberson 2021년 5월 11일
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.

댓글을 달려면 로그인하십시오.

Community Treasure Hunt

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

Start Hunting!

Translated by