Classify binary images with multiple features

조회 수: 2 (최근 30일)
Edward Attard Montalto
Edward Attard Montalto 2018년 4월 6일
답변: Prajit T R 2018년 4월 9일
I'm trying to classify a set of binary images in matlab. I have created a model using a lot of different images and have classified each one accordingly so that the model 'knows' which images belong to which class. Each image is represent as a feature vector, which is 1x59. I am successfully able to calculate the mean and covariance of class of images. The classifier uses maximum a posterior classification (MAP), but for some reason all the images in the test aren't being classified properly. The long equation I am using in the variable 'score' is the MAP calculation . Does anyone have any suggestions as to how to best classify an image?
function [classname] = classify(imagepath)
%Classify the image specified for the given image path
load('models');
%Assume all models use the same number of features
N = length(models(1).mean);
%(N+1)/2 because features considers positive and negative fourier
%therefore produces double the number of feature vectors
features = getFeatures(imagepath, ((N+1)/2));
maxscore = -inf;
%Find out which class has the highest score
for index = 1:length(models)
model = models(index);
%this should give a probablist score
score = max(log(model.prior) - 0.5*log(abs(model.cov)) - 0.5*(features - model.mean)'*inv(model.cov)*(features - model.mean));
%Score should be a 1x1 array not that monster
if score > maxscore
maxscore = score;
bestindex = index;
end
end
classname = classes(bestindex);
end

답변 (1개)

Prajit T R
Prajit T R 2018년 4월 9일
Hi Edward
The Deep Learning toolbox can help in classifying images with a good accuracy. Check out this link: Image classification using Deep learning There's another documentation link wherein an example with the use of SVM for image classification is given. You may want to try that as well: SVM for Image classification
Hope this helps.
Cheers

카테고리

Help CenterFile Exchange에서 Classification Ensembles에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by