How can i calculate the hogfeature of an image?
1 view (last 30 days)
Show older comments
I have a code of hog which i am running and it is working fine. I understand almost every part of it but couldn't understand how the hogfeature which is 4680 was calculated? Someone should help me out. The images are 112 x 92 in size. Below is the code
%Load Image
faceDatabase = imageSet('ATT','recursive');
%Display Montage of faces figure;
montage(faceDatabase(1).ImageLocation); title('Images of Single Face in database s1'); figure; montage(faceDatabase(2).ImageLocation); title('Images of Single Face in database s2'); figure; montage(faceDatabase(3).ImageLocation); title('Images of Single Face in database s3'); figure; montage(faceDatabase(4).ImageLocation); title('Images of Single Face in database s4'); figure; montage(faceDatabase(5).ImageLocation); title('Images of Single Face in database s5');
%Display Query Image and Database side by side fprintf('Press Enter to select image') pause; [filename,pathname]=uigetfile({'*.png'},'Pick an image file'); galleryImage=imread([pathname,filename]);
figure; for i=1:size(faceDatabase,2) imageList(i)=faceDatabase(i).ImageLocation(5); end subplot(1,2,1);imshow(galleryImage);title('Selected Image'); subplot(1,2,2);montage(imageList);title('Database Image'); pause(0.002) diff=zeros(1,9);
%Split Database into Training and Test sets [training,test]=partition(faceDatabase,[0.8 0.2]);
%Extract and display Histogram of Oriented Gradient (HOG) features for %single face [hogFeature,visualization]=...... extractHOGFeatures(galleryImage);
figure; subplot(2,1,1);imshow(galleryImage);title('Input face'); subplot(2,1,2);plot(visualization);title('HOG Feature');
%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
% Create 40 class classifier using fitcecoc faceClassifier=fitcecoc(trainingFeatures,trainingLabel);
%Test Images from Test Set queryFeatures = extractHOGFeatures(galleryImage); personLabel=predict(faceClassifier,queryFeatures);
%Map back to training set to find identity booleanIndex=strcmp(personLabel,personIndex); integerIndex=find(booleanIndex); figure subplot(1,2,1);imshow(galleryImage);title('Query Face'); subplot(1,2,2);imshow(galleryImage);title('Matched Class');
The line i am talking about is this trainingFeatures=zeros(size(training,2)*training(1).Count,4680).
The Count 4680 is what i am trying to find how it was calculated.
0 Comments
Answers (0)
See Also
Categories
Find more on Computer Vision Toolbox in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!