Extracting Corner Features with PCA and feeding it to neural network

1 view (last 30 days)
I am doing a project on vehicle type classification with Neural Networks( classification basis is => sedan,pick up,hatchback,etc type vehicles.)
I am doing image processing for the first time and I have detected about 40 corners using Harris Edge Detection and thus I got a matrix A[40x2].
I am using only this feature as for classification.
Now I want to know how can I use PCA to extract features from it.I know what PCA is and what pca(A) or princomp(A)in matlab will return but I dont get how to use the output of pca function as a feature matrix.
1.Does a feature matrix need to be 1-D array.
2.Should I use principle components array which is the 2nd matrix returned by pca function as a feature matrix (its a 2-D matrix)
3.How can I train Neural Network for 3 classes(hatchback,sedan and pickup).
4.Lastly suppose I have N images for each class to train so do I need to train on each image individually or do I have to create a feature matrix that has a extra dimension = N.
please clear my doubts on these

Accepted Answer

Greg Heath
Greg Heath on 6 Nov 2013
% Extracting Corner Features with PCA and feeding it to neural network
% Asked by Adil about 2 hours ago
% I am doing a project on vehicle type classification with Neural Networks( % classification basis is => sedan,pick up,hatchback,etc type vehicles.) % % I am doing image processing for the first time and I have detected about % 40 corners using Harris Edge Detection and thus I got a matrix A[40x2].
A = A(:); % Convert to an 80 dim column
%I am using only this feature as for classification.
%Now I want to know how can I use PCA to extract features from it.I know what PCA is and what %pca(A) or princomp(A)in matlab will return but I dont get how to use the output of pca function %as a feature matrix.
You are on the wrong track
1. Use PCA on all of the data to determine the ranking of orthogonal directions in which the data has the most spread. This is very useful for regression/curve-fitting but not necessarily for classification/pattern-recognition where the importance is on ranking directions of class separation, not total mixture spread.
2. The function PLS is the feature ranking function which is more appropo. I am struggling with it's use because I have not found an explanation which I fully understand. So, I do use PCA even though I know better.
3. I prefer using STEPWISEFIT, the linear model variable reduction function. It's suboptimal but does a great job of ranking the original variables (not orthogonal tranformed ones) for a linear model.
4. So, currently I use STEPWISEFIT However, if the dimensionality is huge,I may use PCA to get rid of obvious losers before using STEPWISEFIT.
5. It is not too hard to code a poor man's stepwise procedure where, for I input variables, performance is obtained when one of the variables is fixed at it's mean value. The variable associated with the best performance is deleted , the net is retrained, and the process is repeated. The procedure is ad hoc and has many variations. Nevertheless, variations are being used, satisfactorily, in real world situations.
% 1.Does a feature matrix need to be 1-D array.
Yes. A feature vector.
%2.Should I use principle components array which is the 2nd matrix returned by pca function as a feature matrix (its a 2-D matrix)
It would not be my first choice. See above.
% 3.How can I train Neural Network for 3 classes(hatchback,sedan and pickup).
Generate many feature vectors for each class (e.g. add noise to the ideal template). Use unit vector columns with a single 1 as targets.
help patternnet
practice on MATLAB classification/pattern-recognition datasets
help nndatasets
Search in NEWSGROUP and ANSWERS
greg patternnet
% 4.Lastly suppose I have N images for each class to train so do I need to train on each image % individually or do I have to create a feature matrix that has a extra dimension = N.
ALWAYS train on all data at once.
Hope this helps.
Thank you for formally accepting my answer.
  5 Comments
Adil
Adil on 9 Nov 2013
What if I use Gabor Filters instead of PCA (I read that they are efficient as they simulate visual cortical cells and filters are oriented in differenct directions to extract the feature ) ..
Alex
Alex on 23 Jan 2019
@Adil: Could you share your success if it worked for you or not. I am in a similar situation.
Sorry, I didn't mean to hijack OP's thread.

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!