Classify binary images with multiple features
4 次查看(过去 30 天)
显示 更早的评论
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
0 个评论
回答(1 个)
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
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Classification Ensembles 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!