2
votes

I found out the HOG feature vector of the following image in MATLAB.

Input Image

I used the following code.

I = imread('input.jpg');
I = rgb2gray(I);
[features, visualization] = extractHOGFeatures(I,'CellSize',[16 16]);  

features comes out to be a 1x1944 vector and I need to reduce the dimensionality of this vector (say to 1x100), what method should I employ for the same?

I thought of Principal Component Analysis and ran the following in MATLAB.

prinvec = pca(features);  

prinvec comes out to be an empty matrix (1944x0). Am I doing it wrong? If not PCA, what other methods can I use to reduce the dimension?

1
No. Not PCA. Not again. This won't work. You have only 1 observation and almost 2k features. Impossible. Please see this canonical answer as to why this is pertinently impossible. - Adriaan
@Adriaan Thanks man. I just realized what I should really do. I should loop through each frame of the video and form a Nx1944 HOG matrix and then apply PCA. Is that right? - Abdul Fatir
Possibly, if N > 1e4, see my answer I linked on why you need some 5 times more observations than features. - Adriaan
Yes, can you write everything you mentioned as an answer so that I can mark it as an answer. - Abdul Fatir
what features are you trying to extract and what is your ultimate goal? looping through the video and applying PCA to the final feature matrix will not necessarily give you what you want - GameOfThrows

1 Answers

5
votes

You can't do PCA on this, since you have more features than your single observation. Get more observations, some 10,000 presumably, and you can do PCA.

See PCA in matlab selecting top n components for the more detailed and mathematical explanation as to why this is the case.