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