MATLAB Answers

Please help me to understand the PCA usage.

1 view (last 30 days)
saeeda saher
saeeda saher on 7 Jun 2018
Commented: Adam on 8 Jun 2018
I want to use HOG for feature extraction and want to apply PCA for dimension reduction ,I found this code but did not understand the PCA function usage. Please make me understand how PCA function is used and what results its providing or Is it used in the code in correct way, If not please help me to make it correct.
% Features Extraction of Face based on HOG
clear;
training=imageSet('Dataset\','recursive'); % folder name of the database
K=1;
for i=1:size(training,2 )
for j=1:training(i).Count
Face=read(training(i),j);
Face=imresize(Face, [48 48]);
%Face=rgb2gray(Face); %If color images
Face = pca(double(Face));
HOG_Features= extractHOGFeatures(Face);
trainingFeatures(K,:)=single([HOG_Features]);
traininglabel{K}=training(i).Description;
K=K+1;
end
persons{i}=training(i).Description;
end
traininglabel=traininglabel';
csvwrite('Test.csv', trainingFeatures)
  3 Comments
Adam
Adam on 8 Jun 2018
I have never worked with HOG features, but if the PCA is being done before the HOG then in this case it is because whoever wrote the code wishes to reduce the dimensionality of their original data before extracting features from the resultant dimension-reduced data. This will remove redundancy that may be present in the original data and can cause feature extraction to either be inefficient or simply not work as well.

Sign in to comment.

Answers (0)

Community Treasure Hunt

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

Start Hunting!