필터 지우기
필터 지우기

Compare images with svm

조회 수: 2 (최근 30일)
Marcin Kowalski
Marcin Kowalski 2017년 8월 3일
답변: kurakula sairam 2017년 12월 15일
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?

답변 (1개)

kurakula sairam
kurakula sairam 2017년 12월 15일
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

카테고리

Help CenterFile Exchange에서 Get Started with Statistics and Machine Learning Toolbox에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by