Compare images with svm
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Hi,
I am trying to use SVM for comparison of two facial images based on extraction of various features. While SVM works fine for multi-class classification, comparing two images seems a bit more difficult. Basically, I have a set of pre-processed images of faces after detection and segmentation. The code is following:
%%Extract Features for training set
training=imageSet('Y:\Bazy biometryczne\Face\att', 'recursive');
for i=1:3
personA = 1;
Pa=read(training(personA),i);
Pa=Pa(:,:,1);
% normalization
Pa=double(Pa);
Pa=(Pa-min(Pa(:)))/(max(Pa(:))-min(Pa(:)));
% figure, imshow(Pa, [])
trainingFeatures(i,:) = extractLBPFeatures(Pa);
trainingLabel{i} = training(personA).Description;
end
for i=1:3
personB = 2;
Pb=read(training(personB),i);
Pb=Pb(:,:,1);
% normalization
Pb=double(Pb);
Pb=(Pb-min(Pb(:)))/(max(Pb(:))-min(Pb(:)));
% figure, imshow(Pb, [])
trainingFeatures(i+3,:) = extractLBPFeatures(Pb);
trainingLabel{i+3} = training(personB).Description;
end
%%train binary classification
% SVMModel = fitcsvm(X,Y,'KernelFunction','rbf','Standardize',true,'ClassNames',{'negClass','posClass'});
faceClassifier = fitcsvm(trainingFeatures,trainingLabel,'Standardize',true,'KernelFunction','linear' );
%%Test Images from Test Set
personA1 = 1;
queryImage = read(training(personA1),4);
% normalization
queryImage=double(queryImage(:,:,1));
queryImage=(queryImage-min(queryImage(:)))/(max(queryImage(:))-min(queryImage(:)));
figure, imshow (queryImage,[])
queryFeatures = extractLBPFeatures(queryImage);
[personLabel, score] = predict(faceClassifier,queryFeatures)
As you can see, I am training the classifier with two sets (face of two persons) of 3 images. At the end I check if the test image is from one of the classes. Everything works great when I use an image from training. The problem appears when I use image of the trained person which was not used for training - it does not point correct person.
Generally, I tried with various different features but with no results. What would you suggest to me?
0 Kommentare
Antworten (1)
kurakula sairam
am 15 Dez. 2017
hey dude i have run this program and it works good after changing 1:3 to 1:4 for i value and can you tell me how to proceed this for N persons
0 Kommentare
Siehe auch
Kategorien
Mehr zu Get Started with Statistics and Machine Learning Toolbox finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!