-
Notifications
You must be signed in to change notification settings - Fork 0
/
BOF_new.m
32 lines (26 loc) · 1.04 KB
/
BOF_new.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
%%
imgSets = imageSet('.\MarsObjects','recursive');
%%
[trainingSets, testSets] = partition(imgSets, 0.3, 'randomize');
%bag = bagOfFeatures(trainingSets,'Verbose',true,'GridStep',[8,8],'VocabularySize',80,'PointSelection','Detector');
bag = bagOfFeatures(trainingSets,'Verbose',true,'VocabularySize',100,'PointSelection','Detector');
categoryClassifier = trainImageCategoryClassifier(trainingSets, bag);
%%
confMatrix = evaluate(categoryClassifier, testSets);
%%
testSets=imageSet('.\BiggerObjects','recursive');
%%
imset = imageSet('.\BiggerObjects','recursive');
numObj = numel(imset); % number of different objects
numImEachObj = [imset.Count]; % number of images for each object
totalNumIm = sum([imset.Count]); % number of images in total
%%
for no = 1:numObj
numIm = imset(no).Count; % number of images for this object
disp(imset(no).Description)
for ni = 1:numIm
img = imset(no).read(ni);
img = imtranslate(img,[randi([-50,50]),randi([-50,50])]);
predict(categoryClassifier,img)
end
end